Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create exe file to run java applicat 1

Status
Not open for further replies.

ajuking001

Programmer
Mar 30, 2001
3
JP
I am a junior programmer and want help regarding creating a self executing java application. For example , I have created an application and not an applet. Using the jdk what i have is the class file/s. I want the class files to be encompassed into some kind of a exe file or use other means to create exe files whereby I want the application to be executed on double click of that single file from windows and not from the dos prompt or a web browser .
Any suggestions ?

ARCHIE
 
If you are sure you know the location of your JVM of choice, you can write a simple C launcher program and compile it with your C compiler of choice (GCC, Inprise's C Builder, MS VC, etc. (GCC is free at
The program would be something like this:
========
#include <stdlib.h>
int main(int argc, char *argv[])
{
return system(&quot;c:\\path\\to\\jvm\\java javaclassname&quot;);
}
=======

Alternately, you could muck about in the Windows settings to associate the .class file type with your JVM so Windows launches the JVM when you double-click on the .class file. I haven't had too much success there. I suspect that Windows actually passes the full file name to the JVM instead of passing the filename sans the .class extension.

Please let me know if that worked out for you.
 
Hi Archie,

Maybe you would like to take a look at this link:

Please take note that this software doesn't support all java functions yet.

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Hey Archie,

If you are using Windows, which I assume you are, and you are doing this for your own personal use, what I did was create a shortcut on my desktop by right clicking on the desktop and selecting new->shortcut. From there a wizard will appear which requests a path for your shortcut. You can even change the icon by right-clicking on the icon then selecting properties for the popup menu-> shortcut tab-> change icon... button. Of course, this is just a quick fix, not a permanant solution. Let me know if you have any questions.

Regards,
Craig Snowbarger
 
Hi,

You can also create an executable jar file.
Executable jar files are jars that contains a specific file (a &quot;manifest&quot;) indicating the class which main method will be called.

Suppose you have all your application classes stored from the path .\foo
Then you create your jar file :
$>jar cf my_jar.jar foo
Suppose you want to execute the main method of the foo.FooApp class in jour jar file when needed. Then you have to write a simple &quot;manifest&quot; file, for example :

Manifest-Version: 1.0
Main-Class: foo.FooApp
Created-By: 1.2 (Sun Microsystems Inc.)

Call this file manifest-foo, for example, then you create your executable jar file by adding this manifest :
$>jar ufm my_jar.jar manifest-foo

This jar file can be double clicked to be executed, or by command line :
$>java -jar my_jar.jar

Note that your jar file can be executed regardless the platform being used.

Bye
--
Globos
 
You can create a command file and include the line

java -cp <path to class files> <class with main>

java -cp c:\objects Program.jar

where Program.jar contains a manifest pointing to a class with a main, and java.exe (from Java RunTime Environment,) is in the path.


or you can write an application that executes that same command line.

you can't make an exe and have it still be java.

 
I think Microsoft's Java ver 4.0 has the facility to make an exe of a .class file but I haven't tried it out so you can just download it from Microsofts home site and check out the exe &quot;jexegen.exe&quot; in bin directory. I really don't know its use. If any body knows that I'm wrong then please let me know. And if it works then please let me know, how it works.
 
Downloading the MicroSoft SDK for Java is the easiest way to make executables. You put al class files needed in one directory and run jexegen. You only have to enter the main class. And there you have a windows executable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top