如何在VS Code中反编译Java类文件

huangapple go评论71阅读模式
英文:

How to decompile Java Class file in VS Code

问题

以下是翻译好的部分:

"所以我是一个新的Java开发者,目前我使用的是VS Code平台。据我理解,在Java中每次创建一个新的对象时,应该会生成一个类文件。正如在这个视频中所解释的:

视频链接
从分钟标记"3:00"开始。

我的问题是,无论我运行程序多少次,它都不会自动创建类文件,即使手动创建类文件也是如此。当我尝试手动创建一个类文件时,我会收到以下消息:

"This file is not displayed in the text editor because it is a Java class file. Click here to decompile and open."

解压缩后,我会收到以下消息:

"Error while getting decompiled source."

我真的需要一些建议和帮助,我已经尝试了大约一周了。我尝试配置路径,安装/卸载扩展程序,重新安装JDK。我想我真的不知道我在做什么,有人可以帮助我吗?

所提供的图像是每次手动配置类文件时发生的情况的示例。它不会自动配置。"

英文:

enter image description here

So I'm a new java developer and VS code is currently the platform I use. To my understanding every time you create a new object in Java, a class file should be generated as well. As explained in this video
{
https://www.youtube.com/watch?v=dFuVh_Bzy9c&list=PLsyeobzWxl7pe_IiTfNyr55kwJPWbgxB5&index=50&ab_channel=Telusko
beginning from min mark "3:00"
}
My problem is that whenever I run my program it doesn't create a class file automatically even when creating a class file manually. When I try to manually create a class file I get this message,

"This file is not displayed in the text editor because it is a Java class file. Click here to decompile and open."

After I decompile I get this message
"Error while getting decompiled source."

I just really need some advice and help I've been trying to figure this out for about a week now. I tried configuring the paths, installing/uninstalling extensions, reinstalling the JDK. I guess I really just don't know what I'm doing can someone please help me.

The image provided is an example of what happens every time. This only pops up after trying to manually configure a Class file. It doesn't configure automatically.

答案1

得分: 0

你想编译还是反编译?我认为你需要编译。如果是这样,请修复问题标题。

作为一个有经验的NetBeans、Eclipse、IntelliJ和Visual Studio Code用户,我建议你在Java开发中使用Eclipse。不要使用Visual Studio Code。那个IDE非常适合C#和JavaScript。

如果你选择了Eclipse,我可以帮助你配置你的工作空间。

使用VS Code编译Java

无论如何,如果你想使用VS Code,基本上你需要尝试插件并进行配置 :/

使用命令行编译

由于你正在尝试简单的类,你可以使用命令行来编译和运行你的Java类。这种方法是超级快速的方式,甚至比Eclipse更快

  • 在你的机器上安装Java
  • 使用 java -version 验证
  • 使用 javac Please.java 编译
  • 使用 java Please 运行

如何在VS Code中反编译Java类文件

你可以继续使用VS Code进行开发,并像专业人士一样使用命令行进行编译。

英文:

Do you want to compile or decompile? I think you need to compile. Fix the question title if this is true.

As a experienced user in netbeans, eclipse, intellij and visual code, I recommend you to use eclipse for java development. Don't use visual code. That ide is perfect for c# and javascript.

If you choose eclipse, I can help you to configure your workspace.

Compile java with vs code

Anyway if you want to use vs code, basically you will need to try plugins and configure them :/

Compile with cli

Since you are trying simple classes, you could use the shell to compile and run your java class. This method is the ultra fast way to do it, even faster than Eclipse

  • install java in your machine
  • validate with java -version
  • compile with javac Please.java
  • run with java Please

如何在VS Code中反编译Java类文件

You could continue using vs code to develop and the shell to compile like a pro.

答案2

得分: 0

VS Code 不会自动创建 Java 类文件。如果您想要创建一个类文件,只需运行 javac Please.java,这将创建一个 Please.class 文件。然后,您可以在终端中键入 java Please 来运行此文件。

例如:
创建一个示例 HelloWorld 的 Java 文件
如何在VS Code中反编译Java类文件

当我创建此文件并在右上角的运行按钮上运行它时,它只会输出 Hello World,并不会创建任何 Java 的 .class 文件。

但如果我想要一个 Java 的 .class 文件,我可以使用 javac 创建它。为此,我只需在终端中键入 javac HelloWorld.java
如何在VS Code中反编译Java类文件

现在,.java 文件已编译成 .class 文件。
当我点击反编译类文件时,它只会将 .class 文件反编译为 Java 源文件。
如何在VS Code中反编译Java类文件

英文:

VS Code doesn't create Java class files automatically. If you want to create a class file just run
'javac Please.java'
this will create a Please.class file
You can now run this file by typing 'java Please' in the terminal

For Ex:
Creating a sample HelloWorld java file
如何在VS Code中反编译Java类文件

when I created this file and run it using the run button present in the top right corner, It just output Hello World and does not create any java .class file.

But if I want a java .class file, I can create It using javac.
For that I just wrote in the terminal
'javac HelloWorld.java'
如何在VS Code中反编译Java类文件

And now the .java file is compiled into a .class file
When I click on Decompile Class File
It just decompiles .class file into a Java source file
如何在VS Code中反编译Java类文件

huangapple
  • 本文由 发表于 2023年7月6日 13:10:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76625681.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定