This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes convert java application to exe file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "convert java application to exe file" Watch "convert java application to exe file" New topic
Author

convert java application to exe file

vijayakumar durai
Ranch Hand

Joined: Aug 18, 2008
Posts: 153
can any body tell how to create java application to exe file?


thanks in advance
Sanjay KumarB
Greenhorn

Joined: Aug 10, 2009
Posts: 6
You can create the setup.exe file for a java application using some tools like installshield, installJammer, installanywhere. But these softwares are not freeware.

And one more problem is like, the user who installs your java application should have the JRE. So its not applicable in small applications.

Example, I have created one Calculation application. Only one class is there that extends JFrame and has implementation for basic calculation process. The whole application size will be less than 500 KB. But to run this, one needs a JRE. So you have to keep this JRE file along with your application for installation.

So if you will see logically, why an user will agree to install a JRE of more than 70 MB for an application of size 500 KB.


Regards,

Sanjay Kumar


.~~ If you can't win by your strength, then win it by opponent's weakness ~~.

Cheers Gambit Shaan
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

Sanjay KumarB wrote:You can create the setup.exe file for a java application using some tools like installshield, installJammer, installanywhere. But these softwares are not freeware.

Inno Setup and NSIS are, and can do the same.

But you are right, Java code can (as far as I know) not be compiled into real native code on Windows*, and so it will always require a JVM installed on the system.


* For Linux you have GCJ which has ported a subset of the core API to native code. It lacks a lot of user interface code (from Swing mostly) though.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 452

why do you want to convert it into an exe file ??? by converting it you are just making it unportable in my opinion.
compress the byte code of your application in a jar file and it can be executed just by clicking over it twice (if you have installed the jre ).

otherwise you can use one of above mentioned jar to exe converters.
avi sinha


SCJP 5.0 SCWCD 5.0
vijayakumar durai
Ranch Hand

Joined: Aug 18, 2008
Posts: 153
we created jar file it will like winzip format if we double click can any body tell how to create jar file if we click the jar file our application will run?



thanks in advance
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 452

vijayakumar durai wrote:we created jar file it will like winzip format if we double click can any body tell how to create jar file if we click the jar file our application will run?
thanks in advance


there is no any difference in the command which is used to create a jar file. it depends upon the application being used to open it.
many compressing tools like winRar , winZip etc consider a jar file as a compressed file .( its correct) but it can be executed by executing it using java runtime file .

How to run a Jar file

avi sinha
vijayakumar durai
Ranch Hand

Joined: Aug 18, 2008
Posts: 153
i have created jar file Myjar.jar if i run in dos prompt java -jar Myjar.jar it execute application when i double click jar file it will open in notepad. i need if i double click the jar file application will run is there any software need what i have to do ?









thanks in advance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41586
    
  54
when i double click jar file it will open in notepad. i need if i double click the jar file application will run is there any software need what i have to do ?

You need to associate one of the JVM executables with jar files, probably java.exe or javaw.exe. This normally happens during JVM installation; maybe the setting got changed up later.


Ping & DNS - my free Android networking tools app
Alex O. Sul
Greenhorn

Joined: Nov 06, 2009
Posts: 3

You can use the Fat Jar Eclipse Plug-In (avaliable on this page) to generate an executable jar file and run your program with double click


SCJP 5
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Road Bike, please check your private messages.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
vijayakumar durai
Ranch Hand

Joined: Aug 18, 2008
Posts: 153
i have changed jar file to open applcation in java setting mycomputer->tools->folderoptions->filetypes->jar file in this path i click the change and set the jdk->javaw.exe .if i double click the jar file .i got error couldnot find main class program will exit . i am not able to run in dos prompt also

can any body tell how to associate jvm with jar file?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

What's in your manifest file? Also, unfortunately, javaw shows this message for any exception thrown by the JVM. The problem may be something completely different. Try running the JAR file from the command line: That will show you exactly what is going wrong.
vijayakumar durai
Ranch Hand

Joined: Aug 18, 2008
Posts: 153
ok i will explain full details of what i done


i have created Manifest.txt


MyClass.java


then i create jar file

jar cvfm myjar.jar Manifest.txt *.class

now i can able run in dos prompt

if i am double click jar file. i got error couldnot find main class program will exit can any body tell how to associate jre with jar file
















Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38426
    
  23
Does this Java™ Tutorials page help? Did you enter new line after the main class name?
vijayakumar durai
Ranch Hand

Joined: Aug 18, 2008
Posts: 153
i checked ftype in dos prompt

D:>assoc .jar
.jar_auto_file

D:>ftype jar_auto_file

jar_auto_file=%SystemRoot%\32\NotePad.exe %1

i got notepad but i need javaw.exe


can anybody tell how to change association for jar file?
vijayakumar durai
Ranch Hand

Joined: Aug 18, 2008
Posts: 153
when i am setting jar open file path like"C:/sun/jdk/bin/javaw" like i dont have advance option anybody tell what i have to do?
vijayakumar durai
Ranch Hand

Joined: Aug 18, 2008
Posts: 153
can anybody tell what i have to set at the installation of jdk?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38426
    
  23
vijayakumar durai wrote:can anybody tell what i have to set at the installation of jdk?
As far as I know, nothing unusual.
vijayakumar durai
Ranch Hand

Joined: Aug 18, 2008
Posts: 153
thanks friends i got
Samuel Behrman
Ranch Hand

Joined: Oct 02, 2009
Posts: 49
You can use native compilers but produced applications are native and there are a lot of problems with debugging.
(http://www.geocities.com/SiliconValley/Lakes/6686/jcomp.html#native)

My advise is to use exe that launches java virtual machine. These are tools similar to javaw application, which contain information about classpath, java and app parameters internaly. They load jvm.dll (java.dll) and invoke main method of main class.

You can visit http://www.geocities.com/j2exe
There is a free tool for non-comercial use.


RAQ Report: Web-based Excel-like Java reporting tool.
 
 
subject: convert java application to exe file