Compiling only one class in a project

I have build disabled automatically , and I want to build only one class (for debugging). Is it possible? Other classes are already compiled in the assembly directory, but they may not compile in Eclipse.

+4
source share
4 answers

I think you can by going to the Project menu and choosing Build Working Set → Select Working Set.

Choose a new one, give your set a name, and select only one class that you want to create. After that, it should be built.

The next time you want to build, go to the Project menu and select Build Working Set → and the name of the set you created.

+3
source

I think Eclipse is smart enough to recompile only those classes that you actually somehow changed (even if other classes cannot be compiled). Therefore, if you turn on automatic assembly, edit the class and save it, Eclipse will recompile just that. I doubt that Eclipse will recompile the entire code base if, for example, you rename one of your variables to this class.

The bottom line is: stick to an automatic building.

If you have a special use case, then it would be nice to know what it is. Other than that, James's answer may be your best shot.


I created a small Maven project for myself in Eclipse (although this is a Maven project, the automatic build of Eclipse works fine, like in a Java project, without magic).

. |-- pom.xml |-- src | `-- main | `-- java | |-- A.java | `-- B.java // B contains erroneous "stuff" `-- target `-- classes |-- A.class // A compiles without a word `-- B.class // even though it contains errors // B compiles too ... weird 

(Note that nothing is displayed under the destination folder in the package / project browser window. I may be representing things, but usually the classes and other things are listed there ... not sure.)

+1
source

For some reason, eclipse did not restore my classes when using JRebel and auto build off when I select Build Project. As a workaround, I added a main method referenced by another class that I would like to build (by printing OtherClass.class in sys out basically), and then executed the main method using Run as Standalone.

2 files part of the web application. Therefore, when they were compiled, tomcat had new class files, and I did not have to restart (this takes 15 minutes due to many modules).

0
source

It's quite simple: right-click on your class in the Package Explorer, and then select "Export ..."

What is it.

0
source

Source: https://habr.com/ru/post/1383658/


All Articles