I\'ve compiled a java project into a Jar file, and am having issues running it.
When I run:
java -jar myJar.jar
I get the following err
You should specify your main class during jar creation with full path, something like:
<target name="jar" depends="compile">
<delete file="myJar.jar"/>
<delete file="MANIFEST.MF"/>
<manifest file="MANIFEST.MF">
<attribute name="Main-Class" value="my.package.myClass"/>
</manifest>
<jar destfile="myJar.jar"
basedir="."
includes="**/*.class"
manifest="MANIFEST.MF" />
</target>
In your manifest file, make sure you have the attribute Main-Class
set to the name of the class containing your main()
method. For example, if the package-qualified name of the class is my.cool.Class
, then, in your JAR manifest, Main-Class
should be set to my.cool.Class
.
Also made sure that you have a package declaration in your .java
files (for example, in Class.java
, make sure you have the proper package my.cool;
declaration). Also, make sure your directory hierarchy is set up correctly (my.cool.Class
should be in $SRC/my/cool/Class.java
).