Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Jim Carr
Jim Carr
22,635 Points

Deploying Java programs

Is there a course or can you cover the deployment of a Java program? Craig Dennis did an awesome job introducing a Java IDE but I am having trouble finding what to do with the program once it is written. Thank you.

1 Answer

If you are using an IDE, you should have the option to export the program as a runnable JAR file ("Java Archive").

If you are using the command line, there are a few more steps: 1) Open Command Line 2) Navigate to the folder containing the compiled java code for your program. Note: it will contain .class files. 3) type: jar cvfe MyJarName.jar MyMainClass .class -MyJarName will be the name of the .JAR file -MyMainClass is the name of the Class with your main method. -.class selects all .class files in the current directory 4) You should now have an executable JAR file in that same directory.

Jim Carr
Jim Carr
22,635 Points

Thank you, I look forward to trying this. Do you happen to know how to attach a desktop icon to the JAR file?