How to convert .class file to .exe file in windows

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2006
Posts: 24
Reputation: kazek is an unknown quantity at this point 
Solved Threads: 0
kazek kazek is offline Offline
Newbie Poster

How to convert .class file to .exe file in windows

 
0
  #1
Nov 27th, 2008
I wrote a java program/application and I'm trying to combine all the .class files into one .exe file.

I want to have a convenient double-clickable EXE file to launch the program without the user having to handle .java file associations.
Last edited by kazek; Nov 27th, 2008 at 8:27 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,467
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 267
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: How to convert .class file to .exe file in windows

 
0
  #2
Nov 27th, 2008
You don't, you create executable jar files (not "exe"s).

http://java.sun.com/docs/books/tutor...jar/index.html

Edit: And, if you want a "real exe" (i.e. a native executable), then use a language designed to produce a native executable (which Java is not).

If you insist on doing something that will negate all the "advantages" gained by using Java and produce a native executable with it, then Google for some thrid party tools that are designed to do this (there are plenty of them). It is not a recommended course of action, though, so your on your own.
Last edited by masijade; Nov 27th, 2008 at 8:52 am.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 706
Reputation: stultuske is a jewel in the rough stultuske is a jewel in the rough stultuske is a jewel in the rough 
Solved Threads: 84
stultuske's Avatar
stultuske stultuske is offline Offline
Master Poster

Re: How to convert .class file to .exe file in windows

 
0
  #3
Nov 27th, 2008
I had a customer once who wanted .exe files instead of .jar files *sigh* guess how happy he was when he found out his program didn't work so well in Linux

anyhow, an easy-to-use tool to create an .exe from your .jar is NativeJ, an even easier approach to your question would be the search function, since this question has been asked (and answered) a lot of times before.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 823
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: How to convert .class file to .exe file in windows

 
0
  #4
Nov 28th, 2008
There are two ways you can do this. One of them is as described above to pack all .class into one executable jar file which can then be run on any PC that has JRE installed. This can be done through the use of a manifest file (you need to write the main class name into the manifest file so that it knows which class to run). You can lookup this procedure on either the Sun's site or any site that has information for creating executable JAR's. One risk that this procedure runs is that you are basically shipping all your class files which can be potentially decompiled and your source code be exposed to other parties. So if you have the concern of keeping your source code closed you can use the second method mentioned here.
The other method is to use some kind of Java-to-EXE converter software which would take all the class files and optionally the manifest file as input and produce an EXE file as an output. Some of them take theexecutable JAR as input. Shipping an exe file essentially keeps your source code protected. You can also optionally have JRE embedded into the EXE creator during input so that if the target PC does not have JRE installed already you can do it automatically. One such tool is the JexePack which we use, but since this is a licensed s/w you need to purchase copies of it from the vendor.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,467
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 267
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: How to convert .class file to .exe file in windows

 
0
  #5
Nov 28th, 2008
Native executables can be decompiled just as easily as class files. This is a "non-argument".

Edit: And don't ask me how, because I won't tell you. I am not here to instruct people on reverse engineering. I will say this though, "Just because you don't know how to do it, does not mean that it cannot be done."
Last edited by masijade; Nov 28th, 2008 at 6:26 am.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 823
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: How to convert .class file to .exe file in windows

 
0
  #6
Nov 28th, 2008
Hi,
I was recommending just a course of action to a person who seems to be in need. But you look to be insterested in restricting the power of langauges so much that nothing other than the opinions you have seem to be valuable to you. We are certainly not here to discuss how much you and I know, but to solve each others problems. I have just expressed my opinion and the original poster can as well not take my opinion if he feels so. But atleast I offered a solution which you did not even try to. You seem to look so busy in showing off your knowledge.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 706
Reputation: stultuske is a jewel in the rough stultuske is a jewel in the rough stultuske is a jewel in the rough 
Solved Threads: 84
stultuske's Avatar
stultuske stultuske is offline Offline
Master Poster

Re: How to convert .class file to .exe file in windows

 
0
  #7
Nov 28th, 2008
Originally Posted by verruckt24 View Post
Shipping an exe file essentially keeps your source code protected.
yes, we are here to help answering the question, masjiade just pointed out that the information you gave was incorrect.

even so, the question had already been answered, and both answers you gave:
1. create a Jar file
2. use a native program to create an exe
have already been suggested as option, so the only new thing you contributed was another name of a native program, and the error which I quoted you on.

no need to act like an insulted child if someone points that out, since, as you say, we are here to answer these questions and to make sure the original starter of the thread knows what answers contain errors, because, as you put it, we do have our knowledge, and we can filter out the errors, but the starter can't, or he/she wouldn't had to start this thread.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,467
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 267
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: How to convert .class file to .exe file in windows

 
0
  #8
Nov 28th, 2008
No, I was refuting your statement of "Shipping an exe file essentially keeps your source code protected".

You are more than welcome to help, but posting false information (knowingly or not), does more damage than good.

Edit: And that statement that was being refuted is definately not an opinion.
Last edited by masijade; Nov 28th, 2008 at 6:55 am.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 823
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: How to convert .class file to .exe file in windows

 
0
  #9
Nov 28th, 2008
Okay mistake agreed and apologies to the one's hurt.
Thanks for correcting me.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,273
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 544
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: How to convert .class file to .exe file in windows

 
0
  #10
Nov 28th, 2008
I had a customer once who wanted .exe files instead of .jar files *sigh* guess how happy he was when he found out his program didn't work so well in Linux
??? You can run java on linux. Thats the whole entire point of java, is that its Write Once Run Anywhere. A java app should run exactly the same on linux, unix, osx, cellphones, windows.

Just install the JRE on linux and off you go.

"Shipping an exe file essentially keeps your source code protected".
There is always the possibility of disassembly.

Just make a .jre
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum


Views: 5554 | Replies: 19
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC