Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: change java code project to exe file

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Wink change java code project to exe file

    hello , i'm mostafa i finished my java project of super market with a ms access database but i want to change files to exe file and use it ..i know jar files running in all environments but it need JVM , my project is consist 13 class that means 13 jar files and , i want to make them in single jar file can i ? from that i think it's easy to covert it to exe, and i don't want to lose connection with my database ..could any one tell me how .


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: change java code project to exe file

    You can put all the class files and other resources the program needs in a single jar file.
    I use the jar command (part of the JDK) to build and update jar files.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    mostafa_mohamed (September 5th, 2012)

  4. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: change java code project to exe file

    Thanks for your reply
    i don't ask for ability of doing that i ask you to tell me how i do that

  5. #4
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: change java code project to exe file

    Even though it doesn't involve actually converting a jar to an executable format, programs such as AdvanceInstaller do offer nifty tools for packing your jars and resources and installing them to a default directory, be it in AppData or with other program files and then providing a shortcut to your jar in the start menu.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  6. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: change java code project to exe file

    I use the jar command from a batch file. See the doc for the syntax of the command.
    Here is one of the batch files:
    @Rem Create the SlideShowApp.jar file for standalone usage:
    %DEV_DRIVE%
    cd %DEV_HOME%\JavaDevelopment\SlideShow\
    jar -cmf SlideShow.mnf %JAVA_RUN%\SlideShowApp.jar ImgIdxEditor.html
    @REM
    @REM Now go get the tools we need
    @REM
    cd %DEV_HOME%\JavaDevelopment\
    jar -uf %JAVA_RUN%\SlideShowApp.jar SlideShow\*.class NormsTools\GetInput*.class NormsTools\GetIntInput*.class NormsTools\ShowMsgBox*.class NormsTools\MessageArea*.class NormsTools\ChoiceOfYesOrNo*.class NormsTools\ErrDialog*.class NormsTools\MakeEnterDoAction*.class NormsTools\Sorter*.class NormsTools\ArrayUtil*.class NormsTools\FindOurHome.class NormsTools\ShowListBox*.class NormsTools\SaveStdOutput*.class NormsTools\DroppedFileHandlerN*.class NormsTools\NormsDropTarget*.class NormsTools\OrderingList*.class NormsTools\DroppedFileHandler*.class NormsTools\AskMultipleChoices*.class NormsTools\GetPastes*.class
    @REM Done
    @Echo
    @Echo Created: %JAVA_RUN%\SlideShowApp.jar
    @Echo
    @Echo Remember to copy jar file to C:\My_Photos when tested!
    MORE
    The names in % are environment varables.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #6
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: change java code project to exe file

    Follow Norm instructions and then use Jar2Exe tool, freely avaialbe on internet to convert your jar to exe.
    Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.

    - Henry Ford

  8. #7
    Junior Member
    Join Date
    Sep 2012
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: change java code project to exe file

    sorry but i need more explanation about your reply ' norm '

    i couldn't understand any thing

  9. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: change java code project to exe file

    Find the doc for the jar command. It is part of the Java SDK.
    Read the doc and look at the sample batch file I posted that uses the jar command.
    %DEV_DRIVE% is one of several environment variables I use to define paths to folders on my PC.
    If you don't understand my answer, don't ignore it, ask a question.

  10. #9
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: change java code project to exe file

    Do you want to run Java without a JVM? As far as I know, in order for a Java program to run it needs a JVM, even if it's in exe form. Take the Eclipse IDE as an example. It has an .exe version in Windows and a local-binary executable for Linux (there's no application extension in Linux). However, this is just a "dummy program" which runs Java similar to how a batch file or command script would by starting the JVM and running a jar file. Eclipse will not function without an installed JVM.

    The only way to technically run Java without a JVM is on specialized hardware which would treat Java Bytecode as assembly code. I think such hardware exists on some mobile devices, but I'm not positive as many times it's just a JVM ported over to another hardware architecture (for example Android).

    If you want a native application, best to start out with a natively implemented language like C or C++. For Java applications you're likely better off sticking with JAR files, web-start apps, and applets.

Similar Threads

  1. Problem with Java code for Project
    By JavaAsh in forum What's Wrong With My Code?
    Replies: 7
    Last Post: October 19th, 2011, 03:52 AM
  2. [SOLVED] How do I run test code in different file under a project
    By lostbit in forum Java Theory & Questions
    Replies: 1
    Last Post: September 28th, 2011, 11:31 AM
  3. Java I/O File code; how to read/write file
    By ryu2le in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: September 18th, 2011, 05:51 PM
  4. Replies: 2
    Last Post: August 1st, 2010, 06:29 AM
  5. How to change File Type of a File Using java
    By akash169 in forum File I/O & Other I/O Streams
    Replies: 8
    Last Post: March 31st, 2010, 02:58 AM