I would like to compile my Java program in Eclipse but not to run it. I can't understand how to do it.
我希望在Eclipse中编译Java程序,但不希望运行它。我不知道怎么做。
How can I compile a Java program to .class
files in Eclipse without running it?
如何将Java程序编译到Eclipse中的.class文件而不运行它?
7 个解决方案
#1
36
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.
您可以在项目菜单中自动取消对构建的检查,然后通过键入Ctrl + B手工构建,或者单击打印机图标右边的一个图标。
#2
9
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.
你需要去Project->Clean…,然后构建您的项目。即使您的源代码不包含作为可执行程序运行的任何主要方法,这也可以工作。类文件将出现在项目的bin文件夹中,在您的工作区中。
#3
3
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.
如果您在Eclipse中删除了.class文件,然后试图从.java文件中重新构建它,那么它什么也不会做。如果您试图在没有.class文件的情况下运行.java文件,您将会得到一个无法找到主类的错误。
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.
您要么必须更改并重新保存.java文件,然后重新构建它,要么必须在项目上运行Clean,然后重新构建。
#4
3
Right click on Yourproject(in project Explorer)-->Build Project
右键单击您的项目(在project Explorer中)——>构建项目
It will compile all files in your project and updates your build folder, all without running.
它将编译项目中的所有文件并更新您的build文件夹,所有这些都不需要运行。
#5
2
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
在这个弹出窗口中,你会发现4个选项卡。1)源2)project 3)Library 4)order and export
Click on 1) Source
点击1)来源
select the project (under which that file is present which you want to compile)
选择要编译的项目(该文件位于其中)
and then click on ok....
然后单击ok ....
Go to the workspace location of the project open a bin folder and search that class file ...
到项目的工作区位置打开一个bin文件夹并搜索那个类文件…
you will get that java file compiled...
您将编译那个java文件……
just to cross verify check the changed timing.
只是为了验证更改的时间。
hope this will help.
希望这将帮助。
Thanks.
谢谢。
#6
2
Try this in your console:
在你的控制台中试试这个:
javac {$PathToYourProyect}/*
If you also need any external library, try:
如果您还需要任何外部库,请尝试:
javac -cp {$PathToYourLibrary}.jar {$PathToYourProyect}/*
#7
1
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
右键单击package Explorer上的文件,然后在它下面显示,到终端Eclipse会有一个终端,然后使用javac文件名进行编译
#1
36
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.
您可以在项目菜单中自动取消对构建的检查,然后通过键入Ctrl + B手工构建,或者单击打印机图标右边的一个图标。
#2
9
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.
你需要去Project->Clean…,然后构建您的项目。即使您的源代码不包含作为可执行程序运行的任何主要方法,这也可以工作。类文件将出现在项目的bin文件夹中,在您的工作区中。
#3
3
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.
如果您在Eclipse中删除了.class文件,然后试图从.java文件中重新构建它,那么它什么也不会做。如果您试图在没有.class文件的情况下运行.java文件,您将会得到一个无法找到主类的错误。
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.
您要么必须更改并重新保存.java文件,然后重新构建它,要么必须在项目上运行Clean,然后重新构建。
#4
3
Right click on Yourproject(in project Explorer)-->Build Project
右键单击您的项目(在project Explorer中)——>构建项目
It will compile all files in your project and updates your build folder, all without running.
它将编译项目中的所有文件并更新您的build文件夹,所有这些都不需要运行。
#5
2
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
在这个弹出窗口中,你会发现4个选项卡。1)源2)project 3)Library 4)order and export
Click on 1) Source
点击1)来源
select the project (under which that file is present which you want to compile)
选择要编译的项目(该文件位于其中)
and then click on ok....
然后单击ok ....
Go to the workspace location of the project open a bin folder and search that class file ...
到项目的工作区位置打开一个bin文件夹并搜索那个类文件…
you will get that java file compiled...
您将编译那个java文件……
just to cross verify check the changed timing.
只是为了验证更改的时间。
hope this will help.
希望这将帮助。
Thanks.
谢谢。
#6
2
Try this in your console:
在你的控制台中试试这个:
javac {$PathToYourProyect}/*
If you also need any external library, try:
如果您还需要任何外部库,请尝试:
javac -cp {$PathToYourLibrary}.jar {$PathToYourProyect}/*
#7
1
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
右键单击package Explorer上的文件,然后在它下面显示,到终端Eclipse会有一个终端,然后使用javac文件名进行编译