Results 1 to 14 of 14
  1. #1
    heartysnowy's Avatar
    heartysnowy is offline Member
    Join Date
    Nov 2008
    Posts
    37
    Rep Power
    0

    Default Convert java to .exe

    I would like to convert one of my java application to .exe or any standalone file so that when I deployed it to another computer, it can be run w/o hving JCreator or any IDE(the software i used to develop).
    Could it be possible to do that? As far as i know, ppl suggested to use third party software to do that magic?

    Any suggestions please..:)

    Regards,
    Hearty

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

  3. #3
    heartysnowy's Avatar
    heartysnowy is offline Member
    Join Date
    Nov 2008
    Posts
    37
    Rep Power
    0

    Default

    may i know where to write that command line?
    i tried it on cmd.exe...but i won't work

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    How did it "not work"?

    BTW, you can use your IDE to create the jarfile, and most systems have file associations to use java to open it automatically on "double-click".

  5. #5
    heartysnowy's Avatar
    heartysnowy is offline Member
    Join Date
    Nov 2008
    Posts
    37
    Rep Power
    0

    Default

    I have no idea, when i type "jar cf archive_name.jar myJava.java" ,it say
    "jar is not recognized as an internal or external command, operable program or batch file"

    When i add "java" at the front, "Exception in thread "main" java.lang.NoClassDefFoundError: jar" .

    my java version is 1.6.0_10 and using JCreator to compile my java files..

  6. #6
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    You need to add the jdk bin directory to your path.

  7. #7
    heartysnowy's Avatar
    heartysnowy is offline Member
    Join Date
    Nov 2008
    Posts
    37
    Rep Power
    0

    Default

    thanks...now i am able to get a jar , i will continue reading the article you sent...
    is it a common behaviour that I wasn't able to run the jar file that i just created?
    Do i still need to further work on to the file to be able to run as an exe file?
    With thanks,
    Hearty

  8. #8
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    You need to compile your code and create the jar file using the class files, not the java files.

  9. #9
    heartysnowy's Avatar
    heartysnowy is offline Member
    Join Date
    Nov 2008
    Posts
    37
    Rep Power
    0

    Default

    yes..i did cr8 jar file using my class file....
    The jar file created was myJava.jar which is "Executable Jar File" with "4KB" size. Even though i double-click it, nth comes out....

  10. #10
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Well, I can only go by what you typed. Try using the options "cef" instead of just "cf".

  11. #11
    racerxadam is offline Member
    Join Date
    Jul 2008
    Posts
    68
    Rep Power
    0

    Default

    you need to include a manifest file in your jar that specifies the Main-Class: attribute to run

    Look at this thread

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by heartysnowy View Post
    yes..i did cr8 jar file using my class file....
    The jar file created was myJava.jar which is "Executable Jar File" with "4KB" size. Even though i double-click it, nth comes out....
    You have to work out with the manifest file also. My advice is do the complete Suns' tutorial first of all. It's really helpful, all the information there you need.

  13. #13
    heartysnowy's Avatar
    heartysnowy is offline Member
    Join Date
    Nov 2008
    Posts
    37
    Rep Power
    0

    Default

    yup...its working now XD...the reason it didn't work at first was I put the wrong main file name in the manifest textfile...Thanks for the support ^^

  14. #14
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    In that sense working on an IDE much better, all what you need for you done by the IDE. Just you have to do few configurations. Working on the command prompt you have to think about a lot.

Similar Threads

  1. Convert .java to .exe
    By susan in forum New To Java
    Replies: 6
    Last Post: 02-11-2009, 07:47 AM
  2. convert html to text using java
    By praveen@asia-mail.com in forum New To Java
    Replies: 1
    Last Post: 11-14-2007, 03:08 PM
  3. how to convert a Java array to a java stack?
    By pompeez in forum New To Java
    Replies: 2
    Last Post: 08-13-2007, 03:41 PM
  4. Can't convert java.lang.String to int.
    By Albert in forum AWT / Swing
    Replies: 2
    Last Post: 07-13-2007, 06:05 PM
  5. convert VB6 applications to Java
    By bbq in forum New To Java
    Replies: 1
    Last Post: 07-05-2007, 04:57 AM

Posting Permissions

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