Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I build a Java project in Eclipse, to create an external JAR

Tags:

java

eclipse

jar

I recently inherited a large software project written in Java. The last developer used Eclipse, so that's what I'm using, but I can't figure out how to build anything. I don't see any build scripts, and when I open the project in Eclipse the "Build All" and "Build Project" options are greyed out.

The project is essentially a huge collection of packages that depend on one another. I know this has to be a simple question but I haven't been able to find an answer through Googling or through just poking around on Eclipse. I'm very new to this IDE - I have worked with Visual Studio for most of my career. Any questions/suggestions would be very much appreciated.

like image 651
Jake Avatar asked Feb 17 '12 05:02

Jake


People also ask

Why can't I add external jars in Eclipse?

However, the 'add external jars' button is greyed out, implying that i am not allowed to use it. Can anyone help? If your project builds with Java 9+ make sure you've selected Classpath (as shown here). You should also be able to add the JAR with right-click on the project > Build Path > Add External Archives....

How do I export a java project as executable jar in Eclipse?

To export your project, right-click it and select Export. Select Java > Runnable JAR file as the export destination and click Next. On the next page, specify the name and path of the JAR file to create and select the Launch configuration that includes the project name and the name of the test class.


1 Answers

File -> Export -> Export JAR File. Then select your project, press next twice, select the main class.

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

If you just want to run, open the main class and click the green arrow at the top.

enter image description here

If you just want to build class files, I believe that Eclipse automatically builds every time you save. You need to select Project -> Build Automatically

enter image description here

like image 84
Ryan Amos Avatar answered Oct 09 '22 08:10

Ryan Amos