How can I compile a Java program in Eclipse without running it?

后端 未结 7 1739
感情败类
感情败类 2020-12-12 23:40

I would like to compile my Java program in Eclipse but not to run it. I can\'t understand how to do it.

How can I compile a Java program to .class files

相关标签:
7条回答
  • 2020-12-12 23:42

    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

    0 讨论(0)
  • 2020-12-12 23:43

    Try this in your console:

    javac {$PathToYourProyect}/*
    

    If you also need any external library, try:

    javac -cp {$PathToYourLibrary}.jar {$PathToYourProyect}/*
    
    0 讨论(0)
  • 2020-12-12 23:45

    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.

    0 讨论(0)
  • 2020-12-12 23:57

    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.

    0 讨论(0)
  • 2020-12-13 00:02

    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.

    0 讨论(0)
  • 2020-12-13 00:02

    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.

    0 讨论(0)
提交回复
热议问题