Jump to content
xisto Community
Sign in to follow this  
vicky99

How To Create Exe File In Java?

Recommended Posts

Dear friendsI came to know that one can build exe files from java application. How this is possible? According to me there is no such method in java to cerate exe files. However Microsoft used to provide a free system development kit (SDK), for Java, which includes the jexegen tool. But one need install Microsoft Java Virtual Machine to run such application. Some people suggest InstallAnyWhere.

Share this post


Link to post
Share on other sites

The way i use is a program called JSmoothdont know the website but you can just goooogle itIt takes all the class files and packages them in an exe file, and when executed searches for the JVM, so you still need to have the JVM on the users computer, but it also has an option to include the JVM ( that would be a big file )anyways check it out, might suit your needs as long as ur programs arent too big....note: i think there is a big in there, you might have to put all ur class files in jar files and have it read them from the jar file for it to work correctly, you might even have to set up the manifest in the jar file to make it be able to execute as a jar if you want it to execute as an exe, not sure though you should test around with it

Share this post


Link to post
Share on other sites

Thanks BitShiftI found JSmooth. But the problem still remains. Say for example I give a java application wrapped with JSmooth to a customer who doesn’t have internet connection. JSmooth will search for internet connection which is not present to download Java virtual machine. So he might have to install JVM manually. Therefore the problem still remains.

Share this post


Link to post
Share on other sites

Thanks BitShiftI found JSmooth. But the problem still remains. Say for example I give a java application wrapped with JSmooth to a customer who doesnât have internet connection. JSmooth will search for internet connection which is not present to download Java virtual machine. So he might have to install JVM manually. Therefore the problem still remains.


hi, first of all, java is not a compiled executable. you can only change how it was packed either in classes or in jar files.

some offer tweaks on how to create an exe file but that is way beyond what i am to tell you.

since java is not a compiled software, it needs to be parse or run in a translater which is the java virtual machine. you can have the java virtual machine packed with your distribution software and write an installer script that will also install the virtual machine.

there are alot of installer scripting software available so i will not pick one. you can google on how to create an installer with executables inside that will automatically be run or setup after install.

--

PS. java is just translated in order for this to run on all machines, dont use microsoft.. microsoft java runs on all machines with windows as they say but that is not true. have a microsoft java software that wont run on a certain version of windows.

no problem with sun java and / or eclipse java in anyway though.

ciao!

Share this post


Link to post
Share on other sites

Dear friendsI came to know that one can build exe files from java application. How this is possible? According to me there is no such method in java to cerate exe files. However Microsoft used to provide a free system development kit (SDK), for Java, which includes the jexegen tool. But one need install Microsoft Java Virtual Machine to run such application.
Some people suggest InstallAnyWhere.

Based upon the phrasing of your question, I'm wondering whether you are
genuinely asking for a Java to native code compiler, or whether you are
simply asking how to write stand alone applications, instead of applets.

Java uses a runtime technology called a JVM - a Java Virtual Machine.
The applets you ran in your browser worked because the browser was able
to load and run a JVM (as a plugin). To write software that does not
require a browser to run, one simply calls the JVM directly, passing it
the name of the class with a special 'main' method. To create user
interfaces you can use classes like Frame in AWT (or JFrame in Swing)
to create windows. The rest of the UI code looks pretty much the same
as an applet, except you are adding it to a Frame object, not an Applet.

Sun's JVM is called 'java' (or java.exe on Windows), and can be run from
a shell/DOS prompt like any other program of that type. Running it
without any options will usually make it print some helpful usage
information.

wojta

Share this post


Link to post
Share on other sites

Thanks BitShiftI found JSmooth. But the problem still remains. Say for example I give a java application wrapped with JSmooth to a customer who doesnât have internet connection. JSmooth will search for internet connection which is not present to download Java virtual machine. So he might have to install JVM manually. Therefore the problem still remains.



I think JSmooth has an option to include the JVM

and even if it doesnt im sure a program out there does, gooogle for one, im sure some1 has made 1 along the way


you cant be the only 1 with this problem

Share this post


Link to post
Share on other sites

Based upon the phrasing of your question, I'm wondering whether you are
genuinely asking for a Java to native code compiler, or whether you are
simply asking how to write stand alone applications, instead of applets.

Java uses a runtime technology called a JVM - a Java Virtual Machine.
The applets you ran in your browser worked because the browser was able
to load and run a JVM (as a plugin). To write software that does not
require a browser to run, one simply calls the JVM directly, passing it
the name of the class with a special 'main' method. To create user
interfaces you can use classes like Frame in AWT (or JFrame in Swing)
to create windows. The rest of the UI code looks pretty much the same
as an applet, except you are adding it to a Frame object, not an Applet.

Sun's JVM is called 'java' (or java.exe on Windows), and can be run from
a shell/DOS prompt like any other program of that type. Running it
without any options will usually make it print some helpful usage
information.



I guess you have misunderstood me. My purpose of asking this question was suppose I have built an accounting software using java and I want to sale it and if my customer does not how to install java. He might does not have even jdk rather JRE. In such cases deploying the software would be very tough. Either I have to personally install the software or the customer has to hire a professional to install the product. That is why the issue of deployment becomes as important as creation. By packing the software with installer along with the classes and JVM the deployment will be much easier and end user friendly.

Share this post


Link to post
Share on other sites

I guess you have misunderstood me. My purpose of asking this question was suppose I have built an accounting software using java and I want to sale it and if my customer does not how to install java. He might does not have even jdk rather JRE. In such cases deploying the software would be very tough. Either I have to personally install the software or the customer has to hire a professional to install the product. That is why the issue of deployment becomes as important as creation. By packing the software with installer along with the classes and JVM the deployment will be much easier and end user friendly.



If this is the case then you should include a JRE that is compatible with your software when you sell it.

If the program you have written needs to be installed on the users PC, in the installer you can write a script to detect to see if they have a JRE installed. If they don't you can have that installer pause and have it automatically open the installer for the JRE that you included.


You should try and do something crafty like this.



Also most computers come with a JRE installed now. If you look around at desktops being selled that come preinstalled with windows and other packages, almost all of them will have some version of a JRE installed, its pretty standard since so much of the web uses Java.
Edited by BitShift (see edit history)

Share this post


Link to post
Share on other sites

Yep - BitShift spelt out the correct installation method for you. There are plenty of free installer software around - one of the best being NSIS Installer, which is immensely customizable using it's own powerful scripting engine.

You should include a copy of the required JRE on your installation CD. You can easily detect the presence/absence of the JRE on the user's computer using NSIS and then fire up the JRE installer automatically if needed.

You can grab NSIS at: http://nsis.sourceforge.net/Main_Page

Share this post


Link to post
Share on other sites

To Answer the origonal question:"How To convert java source code into an executable (.exe)"The Answer is simple, Compile it ! ( just like any c/c++ source code )i dont think SUN have a native java compiler ( javac convers the source to bytecode, to be later run by an interprever ( java ))However, native java compilers do exist.For Example GCJ ( part of GCC, the GNU Compiler Collection )Nativly compiling a java application has its advanatges, for example, you dont need to have JRE installed, but you lose the abbility to "compile once, run on any operating system"good luck.

Share this post


Link to post
Share on other sites

how to connect an .EXE file through java environment

How To Create Exe File In Java?

 

Hello friends,

 

I want to connect an EXE file of cisco software PACKET TRACER using java program, if anyone of you have an idea then please share with me.

 

Thanks

 

-question by vidhu jauhri

Share this post


Link to post
Share on other sites

The way i use is a program called JSmoothdont know the website but you can just goooogle itIt takes all the class files and packages them in an exe file, and when executed searches for the JVM, so you still need to have the JVM on the users computer, but it also has an option to include the JVM ( that would be a big file )anyways check it out, might suit your needs as long as ur programs arent too big....note: i think there is a big in there, you might have to put all ur class files in jar files and have it read them from the jar file for it to work correctly, you might even have to set up the manifest in the jar file to make it be able to execute as a jar if you want it to execute as an exe, not sure though you should test around with it I dont even know what he means by that Lol

Share this post


Link to post
Share on other sites

I know how to write exe files in 256 byte code but I'm not share if I trust you I will show you how to write bmp pictures in javahow to write a pictur I had a hard time I did lots of reverse engineering and hacking to figure out how to write a picture in pure computer codeAll a computer understands is numbers lolOffset   Size   Hex Value   Value Description42 4D "BM"   Magic Number (unsigned integer 66, 77)46 00 00 00   70 Bytes  Size of the BMP file00 00 Unused   Application Specific00 00 Unused   Application Specific36 00 00 00   54 bytes  The offset where the bitmap data (pixels) can be found.28 00 00 00   40 bytes  The number of bytes in the header (from this point).02 00 00 00   2 pixels  The width of the bitmap in pixels02 00 00 00   2 pixels  The height of the bitmap in pixels01 00 1 plane Number of colour planes being used.18 00 24 bits The number of bits/pixel.00 00 00 00   0   BI_RGB, No compression used10 00 00 00   16 bytes  The size of the raw BMP data (after this header)13 0B 00 00   2,835 pixels/meter  The horizontal resolution of the image13 0B 00 00   2,835 pixels/meter  The vertical resolution of the image00 00 00 00   0 colours  Number of colours in the palette00 00 00 00   0 important colours  Means all colours are importantStart of Bitmap Data00 00 FF  0 0 255 Red, Pixel (0,1)FF FF FF  255 255 255   White, Pixel (1,1)00 00 0 0  Padding for 4 byte alignment (Could be a value other than zero)FF 00 00  255 0 0 Blue, Pixel (0,0)00 FF 00  0 255 0 Green, Pixel (1,0)00 00 0 0  Padding for 4 byte alignment (Could be a value other than zeroIf you want to know more about alignment paddingIts to do with the width of your pictureLike this 5 divided 4 = 1.25 is your padding your have .25 which is 00Now remember this .25 is 00 .5 is 0000 .75 is 000000 and if 4 goes right dead on you don't need any padding or 0's after each line of coloursA bmp is written from the bottom up left to rightThe size of the raw BMP data is the Start of Bitmap Data for each set of 2 numbers it counts as 1 bite there's 16 bytes of Bitmap Data on this pictureThe offset where the bitmap data (pixels) can be found. This means how many bytes from the start of the file to where you put your bitmap dataSize of the BMP file this can be calculated by every 2 sets of numbers in the file add them together and you have the picture size in bytesA bmp is backwards in red green blue its blue green red because its how stuff is put in a computer files are mostly read backwards on computer because first number in is the last one out28 00 00 00 is how far it has to go to get to the Bitmap Data you even include this 28 00 00 00 string as 4 bytes all the way to the Bitmap Data witch is mostly 40 bytesHeres a sample code 424D AE000000 0000 0000 36000000 28000000 06000000 06000000 0100 1800 00000000 78000000 130B0000 130B0000 00000000 00000000 FFFF00 FFFF00 FFFF00 FF0000 FF0000 FF0000 0000 FFFF00 FFFF00 FFFF00 FF0000 FF0000 FF0000 0000 FFFF00 FFFF00 FFFF00 FF0000 FF0000 FF0000 0000 FF0000 FF0000 FF0000 FFFF00 FFFF00 FFFF00 0000 FF0000 FF0000 FF0000 FFFF00 FFFF00 FFFF00 0000 FF0000 FF0000 FF0000 FFFF00 FFFF00 FFFF00 0000java codeimport javax.Swing.*;import java.Io.*;Public class hex{BufferedOutputStream bufferedOutput=null;Public hex(){WriteFile("424DAE0000000000000036000000280000000600000006000000010018000000000078000000130B0000130B00000000000000000000FFFF00FFFF00FFFF00FF0000FF0000FF00000000FFFF00FFFF00FFFF00FF0000FF0000FF00000000FFFF00FFFF00FFFF00FF0000FF0000FF00000000FF0000FF0000FF0000FFFF00FFFF00FFFF000000FF0000FF0000FF0000FFFF00FFFF00FFFF000000FF0000FF0000FF0000FFFF00FFFF00FFFF000000","test.Bmp");}Public static void main(String[]args){new hex();}Public void WriteFile(String hex,String f){hex=hex.Replace(" ","");Try{bufferedOutput=new BufferedOutputStream(new FileOutputStream(f));For(int loop=0;loop<=hex.Length()-1;loop=loop+2){int value=Integer.ParseInt(hex.Substring(loop,loop+2),16);BufferedOutput.Write(value);}}Catch(FileNotFoundException e){e.PrintStackTrace();}Catch(IOException ex){ex.PrintStackTrace();}Finally{try{if(bufferedOutput!=null){bufferedOutput.Flush();bufferedOutput.Close();}}catch(IOException e){e.PrintStackTrace();}}JOptionPane.ShowMessageDialog(null,"Done Writeing File");}}

-reply by Damian Recodkie

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.