1

I have a directory in which I generated *.class files. How can I build executable jar file from this files.

What I need to know is

  • how to clean dir
  • how to put all files in jar and make it executable

Sorry people i didnt mentioned, i need do this programmatically in java code.

aleh
  • 297
  • 1
  • 3
  • 8
  • Are you using any IDE like eclipse? If you are using, you can export the classes as executable jar while specifying one main class as entrant. – MaheshVarma Sep 12 '13 at 11:56
  • Have a look at this http://docs.oracle.com/javase/tutorial/deployment/jar/appman.html – Kishore Sep 12 '13 at 11:57

2 Answers2

2
java cfe myJar.jar Classname.class myClass

and for exceution

java -jar Jarname.jar

Creating a Jar

Nambi
  • 11,944
  • 3
  • 37
  • 49
2

If you're using an IDE such as Eclipse or Netbeans, there are specific easier ways to do it. If not I think the following command would work: jar cfe <jar-file> <main-class-name> <class-files...>

BinderNews
  • 570
  • 3
  • 10