CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2010
    Posts
    2

    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
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: How to create an exe file in java

    The jar tool somewhat unsurprisingly produces .jar files, it does not produce .exe files. There are no tools in the jdk to produce .exe files as one of the benefits of using Java is it is platform independent, if you create a .exe then you tie the application to the windows platform.

    If you want to produce .exe files then you have to use a third party tool. There are a number available, some are freely available. Just google for something like "java .exe". If you are having trouble with the tool you currently have either contact a forum for that tool or try another tool.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  3. #3
    Join Date
    Jul 2010
    Posts
    2

    Re: How to create an exe file in java

    Hello,

    You can use Launch4j, it is java executable wrapper.
    refer to this link > http://launch4j.sourceforge.net/

    Hope it can help.

  4. #4
    Join Date
    May 2009
    Posts
    2,413

    Re: How to create an exe file in java

    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.
    .EXE is a Windows format so your programs will run under Windows only. Still if that's what you want you can use a so called native compiler. You can also generate native Java programs to run under Linux.

    http://www.excelsior-usa.com/jet.html

    The only disadvantage is that Excelsior Jet is is commersial product so it will cost you.

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
  •  





Click Here to Expand Forum to Full Width

Featured