如何在 Eclipse 中编译 Java 程序而不运行它?

我想在 Eclipse 中编译我的 Java 程序,但不运行它。我不知道该怎么做。

如何在 Eclipse 中将 Java 程序编译成 .class文件而不运行它?

324917 次浏览

You can un-check the build automatically in Project menu and then build by hand by type Ctrl + B, or clicking an icon the appears to the right of the printer icon.

You will need to go to Project->Clean...,then build your project. This will work, even when your source code does not contain any main method to run as an executable program. The .class files will appear in the bin folder of your project, in your workspace.

In the case that you delete your .class file in Eclipse and then try to build it again from the .java file it will do nothing. If you try to run the .java file without the .class file you will get an error that it can not find the main class.

You will either have to change and re-save the .java file then build it again, or else you have to run Clean on the project then build again.

Go to the project explorer block ... right click on project name select "Build Path"-----------> "Configuration Build Path"

then the pop up window will get open.

in this pop up window you will find 4 tabs. 1)source 2) project 3)Library 4)order and export

Click on 1) Source

select the project (under which that file is present which you want to compile)

and then click on ok....

Go to the workspace location of the project open a bin folder and search that class file ...

you will get that java file compiled...

just to cross verify check the changed timing.

hope this will help.

Thanks.

Right click on Yourproject(in project Explorer)-->Build Project

It will compile all files in your project and updates your build folder, all without running.

Try this in your console:

javac {$PathToYourProyect}/*

If you also need any external library, try:

javac -cp {$PathToYourLibrary}.jar {$PathToYourProyect}/*

Right click on the file on package Explorer Then go to Show in Under it go to terminal Eclipse will have a terminal then Use javac fileName to compile