Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How do I make .exe out my Java?
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
riveryu




PostPosted: Sun Aug 17, 2008 11:11 am   Post subject: How do I make .exe out my Java?

I made a program in Java with the Robot class, I want to make it into a convenient executable.exe. How do I do that?
I'm really new to Java, 2 weeks in with just an almost outdated textbook ( JDK 2 lol).
The Robot class is about the most fun I've had with Java so far haha.
Also, it would be a lot of help if you can point out anything essential changes in Java that you think I should be aware of.
Sponsor
Sponsor
Sponsor
sponsor
Zeroth




PostPosted: Sun Aug 17, 2008 11:47 am   Post subject: Re: How do I make .exe out my Java?

You don't make .exes with Java, as far as I know. If you are using Eclipse, you can export your files as an executable jar. Or, you can do this via command line, but its a lot more complex.
btiffin




PostPosted: Sun Aug 17, 2008 8:40 pm   Post subject: RE:How do I make .exe out my Java?

gcj produces binaries; but their support is currently at java 1.4 (which I have no clue as to what number that is in the new naming scheme). J2SEE-4-New-Yesterday-Beta-7-with-Beans-and-Ginny?? Smile

But if you really want to experiment; check
http://www.javalobby.org/articles/java2exe/ for hints on making .jar files that act as exes (the command lines hinted at by Zeroth) and a few other methods. To stay sane, it may be better to just live with the fact that you need the JVM.

Cheers
Dan




PostPosted: Sun Aug 17, 2008 9:26 pm   Post subject: RE:How do I make .exe out my Java?

Although it is possible to wrap a java class in an exe it is a bad idea as it breaks alot of the main points of using java.

Mostly that java is meant to be platfourm indepednt and run in the JVM. Wraping it in an exe desotrys that and limits it to windows.

It would be a much better idea to inlcude a batch file for windows users that runs the java application in the jvm or even make an exe that simple runs the command to run the java application noramly.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
DemonWasp




PostPosted: Mon Aug 18, 2008 8:42 am   Post subject: RE:How do I make .exe out my Java?

Java's numbering scheme is fairly stupid, but if you just add a "1." in front of anything that doesn't already have a "1." leading it, then you're doing alright (1.5 = 5, 1.6 = 6). Sun has a habit of doing this (they've done it with Solaris, among other things); I disapprove, which is why I call modern Java "Java 1.6".

Dan also has the right of it: you should just jar the java files (you can get your IDE to do it for you in many cases, or you can do it from the command-line (fairly easy; just run jar -h and read about it); if you make it an executable jar, then it will run when double-clicked (assuming correct system setup, etc...). If not an executable jar, then you can just put the run-command (eg. java MyRobots) into a file and name it run.bat - then that's your executable file that users should double-click on.

Why do you need an exe file?
rizzix




PostPosted: Mon Aug 18, 2008 3:27 pm   Post subject: RE:How do I make .exe out my Java?

Don't wrap it in a exe but you can provide an additional .exe algonside it, that will basically run the .jar for you.
riveryu




PostPosted: Tue Aug 19, 2008 5:34 pm   Post subject: Re: How do I make .exe out my Java?

DemonWasp wrote:

Why do you need an exe file?

I "needed" an .exe because I did't know about Jars. Thanks a lot guys.
I just wanted something I can double click on, I simply took a wild guess that Java use .exe. I didn't want to run my fat ass IDE every time.

How do you make .exe that lauch a jar? Do you have to use another language? I don't quite understand .exe right now.
(don't have to tell me about .exe, but it would convenient if someone can explain shortly)

Please explain thoroughly, my previous programming experience includes the following : Turing.
Tony




PostPosted: Tue Aug 19, 2008 5:45 pm   Post subject: RE:How do I make .exe out my Java?

Shortly:
an .exe is a set of executable machine language instructions. Normally your source code is parsed, machine specific instructions are generated from that, and then it's all encoded in binary. An executable is often specific to both the hardware and the type of the OS that runs in between.

When it comes to Java, instead of compiling down to machine specific instructions, source code is crunched down into "ByteCode" -- generic instructions that are later interpreted, in this case by a JVM -- Java Virtual Machine, into something that the hardware under the JVM can understand.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Wed Aug 20, 2008 8:28 am   Post subject: RE:How do I make .exe out my Java?

Addendum to Tony's post:

By making an executable jar file (still .jar), you're making a file that the computer knows how to run when you double-click it. Specifically, it knows it should launch a JVM and invoke it in a way specified by the jar file.

If you were to make a non-executable jar file (also a .jar) then you can call it in any number of ways. One such way is to have another file (.exe or .bat this time) that simply tells the JVM to pick up your jar file and run it in a given way. This can be done in a compiled language (like C, Python, or [I suppoooooose] Turing), or it can be done in a command-line script, such as the Windows .bat file format. Either one of these can launch your Java program fairly easily.

Your easiest option is to just make an executable jar file.
riveryu




PostPosted: Wed Aug 20, 2008 7:40 pm   Post subject: RE:How do I make .exe out my Java?

Thanks guys I made an executable jar of my program. I read the tutorial. Problem solved.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: