• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to make executable jar file

 
Sim Raina
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi i am done with my program and i have only one class and i wanna make into an executabble file.
can somebody tell me how to
from the starting to the end process
thanks in advance
 
Sim Raina
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok now idone making the jar file and i can see it but when i run it , it can't find the main class , does anybody what king of problem isit?
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sim Raina:
ok now idone making the jar file and i can see it but when i run it , it can't find the main class , does anybody what king of problem isit?

Does your jar contain a manifest file? How does it look like?
 
Tom Blough
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sim, within the jar file you need a file called MANIFEST. This file tells the JVM what class is the entry point. To do this, create a file named MANIFEST.MF in your working directory containing the following information:

Where NameOfYourClass is the name of the class containing the entry point. Then include this file in your Jar with the following command:

Where JarFile is the name of the jar file you wish to create.

Hope this helps.
 
Sim Raina
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i do have a mainfest file
and then i did jar -cvfm myresult.jar mainfest.mf *.class
and i did java -jar myresult.jar
and it gives me this error

C:\mysql\data\project>java -jar myresult.jar
Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Message
at readfileTest.main(readfileTest.java:6)
all of my files are compliling and running i don't know what the problem is
and this is the files i have in myresult.jar

C:\mysql\data\project>jar -tf myresult.jar
META-INF/
META-INF/MANIFEST.MF
readfile.class
readfileTest.class
Testing.class
and my manifest files looks like this
------------------------------
Manifest-Version: 1.0
Main-Class: readfileTest
------------------------------
 
Sim Raina
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do u think it is because mail package is in the enterprise edition and it can't read it
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think u forgot to include the jars needed for ur program in ur myresult jar. That's why ur class cannot find the package that it is calling from the main class... Just a suggestion...
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sim: Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Message
javax/mail/Message is a class normally packaged in mail.jar, and I believe you also need activation.jar. Since the classpath is ignored when you run the jar file, you will need to use the "Class-Path" attribute of the manifest file to point to your libraries. Something like this:
Class-Path: libs\mail.jar libs\activation.jar<return>
Note that the list of libraries is space-separated. Here is Jar File Specification
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many, or all, of these problems are covered in the creating an executable JAR thread.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic