View Full Version : Making an executable in Java
Fireman-x
04-16-2002, 02:23 PM
I've been using Jext for a few weeks now, but I just noticed that it's an executable. How would I go about making one of my own programs an executable when it's written in Java?
Dru Lee Parsec
04-16-2002, 06:41 PM
That's not how java works. Each platform has a Java Runtime Environment that knows how to take Java byte code and convert it to machine language that is appropriate to that particular platform.
What you can do it to put your code into a jar file and add a manifest file that describes what the main class is (i.e., the class that has the main method in it). Check out the Java Tutorial here http://java.sun.com/docs/books/tutorial/jar/basics/manifest.html and look about half way down the page. IF you build your manifest file and har the code up then you can run Java code this way:
java -jar jarname.jar
and it will run.
Now, if you really really really want to build an executable program that is no longer WORA (write once run anywhere) then go to the javasoft forumns and search for "java exe" But DO NOT ask about it because it's a question that's been asked about 100,000 times before and the people there get really upset about folks who don't search before they ask.
Essentially there are some tools that can convert Java Byte Code into a Windows32 exe file. But that defies one of the main reasons to write a program in Java.
Romain Guy, Jext's lead developer, has produced an executable version for people who, for whatever reason, don't want to install the Java Runtime Environment. But I've never used it, I always just run it straight from the jar file. Besides, the whole reason I started using Jext was because it looks and works the same on my Windows box and on my Linux box. An exe version would put me back in the "no linux support" position again.
Fireman-x
04-16-2002, 07:11 PM
Ahh, ok. I wasn't sure what Jext was doing. I had assumed it had to do with one of these JIT compilers which I know nothing about ;)
vBulletin® v3.7.0, Copyright ©2000-2010, Jelsoft Enterprises Ltd.