• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to make executable jar file

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
do u think it is because mail package is in the enterprise edition and it can't read it
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many, or all, of these problems are covered in the creating an executable JAR thread.
reply
    Bookmark Topic Watch Topic
  • New Topic