Results 1 to 5 of 5
  1. #1
    pads is offline Member
    Join Date
    Jun 2010
    Posts
    7
    Rep Power
    0

    Default How to create an exe file in java

    Hi I want to create an exe file for my java app.

    I tried with some third party softwares JEXECreator, successfully created the exe file and its working fine in my system, when I tried with another machine, itís not working. I got the following error

    * The error occurred while running the application. The exit code is 0x10000223.
    * Contact the vendor of the application for troubleshooting.

    java.lang.ClassNotFoundException: com.sample.SampleMain
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.ucware.JEXEClassLoader.run(Unknown Source)
    at com.ucware.JEXEClassLoader.main(Unknown Source)
    **************************************

    I know there is something wrong with the classpath which I set.

    Actually I want to create the exe file myself without using any third party software.

    I found the steps in lot of sites

    Created the manifest file named Sample.mft with following contents

    Manifest-Version: 1.0
    Main-Class:
    Class-path:

    In this I have some doubts,

    1. How the Main-Class should be added, with the full package name (com.sample.SampleMain) or the class name alone (SampleMain) or with the extension (SampleMain.class)
    2. How the class-path should be added, I have 4 java classes and 2 jars in my project. How to add all these in the class path, and do I need to add the java jdk in classpath.
    3. Where the manifest file should be saved
    4. What should be the manifest file extension (mf or mft)
    5. In command prompt from which directory I should create the exe file (from my project folder or src folder or the folder which contains all the java classes)
    6. Whatís the syntax should be used while creating jar in command prompt

    (jar cmf Sample.mf Sample.jar Sample1.class Sample2.class Sample3.class Sample4.class jar1.jar jar2.jar) like this or (jar cvfm Sample.jar sample.mf *.class)

    When I did something like this I am getting a jar instead of exe file, When I run the jar in command prompt using "java -jar sample.jar" then I am getting class not found exception".

    Actually how to create an exe file instead of jar file, that means just by double clicking that exe file, should run my app in any machine.

    Can anyone help me to do this?

    Thanks in advance.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default

    You normally don't generate executable .exe files from Java source directly; you generate .class files which, when they start being interpreted, are further compiled to machine code by the JIT compiler. Study .jar files and their generation instead.

    kind regards,

    Jos

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,172
    Rep Power
    20

    Default

    Quote Originally Posted by pads View Post
    Actually how to create an exe file instead of jar file, that means just by double clicking that exe file, should run my app in any machine.
    An executable jar will run on a double click. As Jos says, go through the jar tutorial. Making an exe sort of defeats one of the points about Java.

  4. #4
    UJJAL DHAR is offline Senior Member
    Join Date
    Apr 2010
    Location
    Dhaka,Bangladesh
    Posts
    180
    Rep Power
    0

    Default

    If your JAR file doesn't run on double click,then go to
    Windows window->tools->Folder option->File types->
    select jar executable jar file->Edit->
    make sure that here is written "C:/Program Files/Java/Jdk/bin/javaw.exe" -jar "%1"%* "beside the BROWSE.

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,790
    Rep Power
    25

    Default

    But only if your javaw.exe file is at the path: C:/Program Files/Java/Jdk/bin/

Similar Threads

  1. create the tar.gz file for UNIX plateform in java
    By ashu_knw in forum New To Java
    Replies: 3
    Last Post: 04-16-2010, 12:22 PM
  2. Create an executeable file for java
    By cowboy in forum New To Java
    Replies: 14
    Last Post: 11-04-2009, 12:30 AM
  3. Replies: 5
    Last Post: 08-25-2009, 09:43 AM
  4. How to create exe file in java
    By radix in forum New To Java
    Replies: 8
    Last Post: 11-06-2008, 05:17 PM
  5. Replies: 20
    Last Post: 12-17-2007, 04:20 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •