java - How to make .jar from .class -
i have working .class file when use
jar cvf myjar.jar *.class
i resulting myjar.jar not opened:
"the java jar file “myjar.jar” not launched. check console possible error messages."
thanks helping.
========== edit:
> build > myclass.class > myclasscanvas.class > myclassframe.class > manifest.txt
manifest.txt:
main-class: myclass
as mentioned in comment, need add manifest jar. call manifest.txt , must have @ least following line:
main-class: yourclass # remove comment, leave empty line
yourclass same name yourclass.class file without extension , class must have main method (public static void main(string[] args).
if have main class in subdirectories, must use them (they considered packages. instance if have directory com/foo/yourclass.class
main-class: com.foo.yourclass # remove comment, leave empty line
then pack jar:
jar cvfm myjarname.jar manifest.txt *.class
for more see manifest
edit:
i recommend use @ least maven. make life easier if have other dependencies or so. add , configure maven-jar-plugin , lot of stuff you.
edit:
alternatively, don't need use manifest file, can achieve following command
jar cvfe myjarname.jar myclass *.class
where e - specify entry point - myclass in case
Comments
Post a Comment