tud_mb
tud_mb

Reputation: 65

Does a Jar File need .class files to be executable

currently I'm trying to generate an executable JAR file programatically.

I've been using this thread (How to use JarOutputStream to create a JAR file?) to generate the JAR file but so far it's packed with the native .java files of my test project.

Now I want to know, if its possible to run the JAR file if its only filled with the native classes or do I have to (somehow) compile them into .class files before I can generate the JAR file.

Thanks for your upcoming help!

Upvotes: 1

Views: 365

Answers (1)

Oleg Cherednik
Oleg Cherednik

Reputation: 18245

Jar archive is a zip archive with special folder structure. This structure should have *.class files + resource files. Optionally, sources could be in this archive as well, but this is not reccomended (it's better to provide sources with separate jar file).

Executable jar file is the plain jar file + Manifest.MF where MainClass option exists with a full path (from the root of jar file) to main class with main() method.

Upvotes: 1

Related Questions