Compile Java to Exe?
Hi guys,
I am C++/C# developer. All my products are distributed on Windows platform. Recently, I started programming in Java. As newbie, I have some questions. The most important is - Is any way to make each java application to be started as normal exe application. Also I'm interesting about system tray and windows services. I would like to use them in Java.
Regards,
Real JMan
[412 byte] By [
Real@JMan] at [2007-9-30 12:32:43]

There a lot of professional tools on the market. Some of them are free. Others are not.
Some of them are just launchers. The others are native compilers. I recommend you to use J2Exe (the first one) because it works fine and is easy to be used. You can find there "tray" and "windows services" support. I used it to create some executables for our projects and definitely I can say that I'm satisfied. But you can see others too. Here the list of some of them:
1)J2Exe (http://www.geocities.com/j2exe)
2)Java native compiler (http://www.excelsior-usa.com/home.html)
3)Zerog (http://www.zerog.com)
4)Jexe Pack (http://www.duckware.com)
5)Install4J (www.ej-technologies.com/products/ install4j/overview.html , downloads-zdnet.com.com/3000-2417-10242271.html)
6)JavaExe (http://devwizard.free.fr/)
7)NativeJ (http://www.dobysoft.com/products/nativej/)
> Hi guys,
>
> I am C++/C# developer. All my products are distributed
> on Windows platform. Recently, I started programming
> in Java. As newbie, I have some questions. The most
> important is - Is any way to make each java
> application to be started as normal exe application.
Java Web Start
Executable Jars
Search the forum, asked daily.
> Also I'm interesting about system tray and windows
> services. I would like to use them in Java.
https://jdic.dev.java.net/ has a project for the System tray.
mlk at 2007-7-4 16:14:58 >

cross post http://forum.java.sun.com/thread.jsp?forum=5&thread=536365&tstart=0&trange=15
My God - one day on the forum, five messages posted, and ALL of them a cross-post on one of the most frequently asked qeustions ever:
http://forum.java.sun.com/thread.jsp?thread=536365&forum=5&message=2595010
http://forum.java.sun.com/thread.jsp?thread=536366&forum=57&message=2593068
http://forum.java.sun.com/thread.jsp?thread=536365&forum=5&message=2593067
http://forum.java.sun.com/thread.jsp?thread=536364&forum=422&message=2593066
http://forum.java.sun.com/thread.jsp?thread=536363&forum=406&message=2593065
Fake@JMan, I suppose you can be forgiven because you've never posted to the forum before. But don't cross-post: send your question to ONE topic only. It's considered rude to do otherwise, because it wastes people's time.
This is one of the most frequently asked questions. Do yourself a favor and search the forum before you ask something.
Since Java is cross-platform, you'll need to do non-portable things to access Windoze facilities.
%
Duffymo,Don't you think that you are wrong? I just asked a question ....God bless you, Real JMan
alexi9, thank you for your assistance. it seems that you are professional developer. but please do not write anything as it is me who wrote it. It is stupid to use my nick name.
duffymo, please do not stay in my way. everybody knows how to offend others. don't you thing that no body wins from this? about multiply post ... i have to apologize - sorry.
regards,
real jman
I tried J2EXE But can't understand how to make an EXE from that
I mean I made a setting like this
Java parameters=-classpath BeanPract.jar
Main class=BeanPract.PRACTICE.mdiMenu
Application parameters=
From jar=false
Working directory= %APP_HOME%\..\lib
Environment variables=%JAVA_HOME%=c:\Progra~1\BEA\jdk141_05 "%APP_HOME%=C:\Program Files\Bea\jdk141_05"
Type=JDK without console
Icon=
Output=a.exe
But When I try to run the a.exe file It gives an Error Message
Working directory 'JAcKv~usvhkzcQ9Ll' not found
I could not understand where I m going wrong
Thanks in advance
CSJakharia
Dear CSJakharia,
The problem is obvious. You tried to set %APP_HOME%. This is a reserved variable. Actually it is not environment variable. Rather it is internal constant that represent absolute path to started exe. To make thinks more clear, let suppose that you put generated exe into c:\j2exetest\bin and starts it from there. Then %APP_HOME% is actually c:\j2exetest\bin. So, Do not try to set it!
Something more. In your example you set %APP_HOME%\..\lib as working directory. In other words with our location c:\j2exetest\bin, the working directory of exe will be c:\j2exetest\lib. This is the case where the '.bat' file is located in 'bin' and jars or classes reside in 'lib'. If '.bat' file and jars (or classes) share the same directory you have to put generated exe there and to specify %APP_HOME% as working directory at creation time.
And do not try to set JAVA_HOME. There is no sence because J2Exe relies on Windows Registry to find default JDK and to use it.
Regards, Alexi
Hi Alexi,
I somehow managed to download J2Exe from geocities. Look like the best of tools I have checked so far. Unfortunately I am unable to conver my application into a EXE.
Here are few deatils:
My application relies on a main-class from a JAR file (which I managed to configure from j2Exe and excute it)
Problem is application looks for a resource bundle let say pawan.properties.
I mentioned -classpath variable in Java paramerts along with
-jar pawan.jar -classpath d:\pawan\resources.
Location of pawan.properties is in d:\pawan\resources.
On execution of executable it says count not find resource bundle for properties.pawan. Am not sure how to setup additional classpath so that my properties files are accesssible from EXE application.
Can u help me with this.?
Pawan Sachdeva,
Why don't you take a look at http://www.geocities.com/demo.html . There is an simple example with tutorial. This will be a good start point for you. It will help you very easily to start using J2Exe.
Something more:
I don't think that locating of property file with "-classpath d:\pawan\resources" is a good idea. First of all you have to forget any absolute path because on other machine this path can be different. Instead of this use relative path toward specified working directory. See for more details about reserved keyword %APP_HOME% in demo. Second, set jar file in classpath. Third look for property file using relative path to working directory or Class.getResource()/Class.getResourceAsStream().
Regards, Alexi
There is also article on J2Exe topics at http://www.j2eeworld.com ( http://www.j2eeworld.com/content/view/37/28/ )Good luck, Alexi
Many users complain from "Geocities". Therefore I uploaded J2Exe to http://j2exe.tripod.com . Soon It will be available at http://www.j2eeworld.com too.
Red Hat used GCJ to compile Eclipse for their 64bit version of Linux. Sure, this is a Sun site, hence I'm not surprised to see no mention of GCJ nor Red Hat but this is way cool. http://gcc.gnu.org/java/ http://www.linuxjournal.com/article.php?sid=7413
I have similar problem to Real JMan. I need free application, which convert class files into exe. I want to run this exe program without jre (In all PC with Windows) - all programs on thi topic need jre.Rekus
Argh! Too many people ask this too many times. Just compile the stuff as a regular .class file. Java was designed to be cross platform, not just for one specific OS. There are still people that use other coughbettercough OSs (like I use OS X). Compiling as an exe will just further promote the evil world of Microsoft, and defeat the purpose of java.
Try understand me please. I write program in Java, then I want my friends to used it. Most of them (I can say: all of them) have wINDOWS and no one of them have jre. I want give them only small-size exe (not very small classes + big jre). This is reason why I need java native compiler
rekus at 2007-7-4 16:15:00 >
