JAVA .exe files
JAVA .exe files
For those of us who learned JAVA in schools or on our own, there's always been the
major problem of: the .class file.
The nice folks at Sun gave us the .jar, but still, it requires the JRE and JVM (Java Runtime
Engine and Java Virtual Machine) on the computer where this .jar file will be run.
The solution to this is third party programs. Programs like: EXE4J and JEXECreator.
These are what is called a JIT(Just in time) compilers.
This tutorial will be fore JEXECreator since that is the one I have, tho I have heard the
EXE4J works just fine.
So…go off and download JEXECreator, its got a free demo that needs a serial…;)
Install, open…and lets go: First, you need to start yourself a new project, name it whatever you desire.
Make sure that under the active project pulldown menu, that is the project.
okay, so select the "Output" tab. And fill in the 3 pieces of info this needs. The most
important is the GUI/Console radio button. For those of you wondering which, if your code
works like nmap or JTR and is only black and white "Command Prompt" style text, pick
console…otherwise, GUI is for you.
Now, "Java Settings." The "main class" should be just as it sounds…the class with your
"main method"… public static void main(String args[]) … in it. JVM arguments asks for anything that is passed in via the console to the args[]. If
you have nothing there, set eliminate to true. Minimal Version asks for what JRE you
want. The current version out is 1.5. Some of us still use the old 1.4. What does this
change? Well, pretty much thats in the code you write. Newer versions have extra
features (more libraries, its somewhat dumbed down, no offense). The reason for this
implementation into your .exe is so that if the JRE is not on the computer, it will know
which version to go find.
Alright, now "classpath." This is where you put the code into the program. If you've got
yourself a nice little .jar file, add JAR into EXE, otherwise add the classpath and direct
that to the folder with your .class files. Only have the ones that pertain to this program in
that folder.
Don't bother with "Search Settings."
"Custom Resources" is where you add the fluff to this .exe. Title, Icon. The download URL
is for those people who don't have JRE. Unless your running your own version of JAVA
don't change the first URL. The second can be redirected to your site for help, service, or
FAQS.
The "Message Bundles" are for handling error and other messages. Don't really mess with
this unless you have reason. They are fine the way they are.
Now, click build. Then run. Check your output location. And …your done. Now this builds you a .exe file, which is nice, it still need to be packed with the .class
files tho. It will run on most computers, I think they need the same amount of java
installed as your inet needs. If you find differently pm me and I'll make an edit. I've found
that it works on on any computer.
ghost 18 years ago
heh, no problem. another upside of this is that it takes its speed up to like c++ because it doesnt have to be interpreted. so it makes java much more useful than it already was.
ghost 18 years ago
much less useless* , jk.. relax, wanted to see how you'd react :P, but a nifty little article.
ghost 18 years ago
haha….thanks mate. my grammer blows a big one. lol. thanks for the comment tho. enjoy the article
ynori7 17 years ago
I know i'm reading this like a yar late, but it was a very helpful article. although since i used a free version of JEXECreator it pops up an annoying little alert box before running the program. Any idea how to kill that without buying the program?
ghost 16 years ago
Yes, it does remove the portability of JAVA and removes the JVM (which does a nice job of coddling java code), but in the case that you want your app to be run-able on a box with no JRE, like a school box you cant install it on, this is useful