Sign in to follow this  
n1ck

Java executables

Recommended Posts

hello :) sorry if this questions has been asked a billion times: How do you make a .exe out of a .java? gratias

Share this post


Link to post
Share on other sites
There's really not a good way to do it, at least not with the normal JDK. I think Microsoft's J++ may be able to do it in one way or another, but I don't recommend it (and I've heard that it mutilates the java language quite badly). Why do you need a .exe, though? You can just distribute the Java runtime with your product if you want.

EDIT: There may very well be a way of doing it that I've not heard of, but from what I've seen, people that need .exe files generally just don't use Java.

EDIT: Keep in mind that one of Java's big features is that it's cross-platform (runs on more than just Windows), and .exe is only for Windows executables, so you're kind of defeating one of the reasons for Java's existance if you do that.

Share this post


Link to post
Share on other sites
well, i dont need a .exe but it would be handy.
im pretty new to programming, just taking a java course at my high school but i really like it so trying to expand my knowledge.

is there any easy way to just be able to distribute a java application?
i know there must be or else java would only be good for applets kind of.
by easily distribute i mean like send someone your application so they can just double click it and it runs. thank you very much for feedback

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
What is wrong?

Error : Invalid path, C:\michael\bin\javac.exe -classpath C:\Java -d C:\Java C:\Java\HelloWorld5.java

Share this post


Link to post
Share on other sites
use a DOS-box (WinXP command-console)

- change directory to c:/Java
- check if %path% contains the path to "C:\michael\bin\" by entering "path"
- if it does will "javac HelloWorld5.java" 'compile' your code
- otherwise enter PATH = %PATH%;C:\michael\bin\" once, then use the above, shortened command

Share this post


Link to post
Share on other sites
To the OP:
I don't know java so I might be totally wrong here - but I think what you're looking for is a Jar file... you can use the *nix program "jar" to make them, then as long as you have the java web start package (included with JRE).
[EDIT]As long as you have the java web start package you can run the jar file.
(Ending sentences mid-stride, it may be time for me to go to bed)[/EDIT]

A quick google search turned up this article (pdf warning) which seems to spell out the steps for every way to distribute a java program... the jar method starts on page 5.
http://www.google.com/url?sa=U&start=1&q=http://merganser.math.gvsu.edu/david/reed03/notes/appendixa.pdf&e=10401

Share this post


Link to post
Share on other sites
I could suggest a couple of ways:
-compile the java code to your target machine instead than to the JVM (don't think this is a good idea)
-create a simple batch file:
java -cp . -jar yourprogram.jar
would work in simple situations

-write a c (or delphi or whatever you want) program that does the same things as the batch file, but you can in addition do other stuff. I think this is how OpenOffice or weka work.

Share this post


Link to post
Share on other sites
You could distribute the program with Java web start. That is a technology that allows people to run an application (not an applet) from the web.

I think that all you need is a JVM plugin in your web browser, but I could be wrong. Sorry I don't really know that much about it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this