1,105,310 Community Members

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

Member Avatar
kazek
Newbie Poster
24 posts since Sep 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
masijade
Industrious Poster
4,165 posts since Feb 2006
Reputation Points: 1,351 [?]
Q&As Helped to Solve: 510 [?]
Skill Endorsements: 22 [?]
Team Colleague
Featured
 
0
 

You don't, you create executable jar files (not "exe"s).

http://java.sun.com/docs/books/tutorial/deployment/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.

Member Avatar
stultuske
Posting Expert
5,290 posts since Jan 2007
Reputation Points: 935 [?]
Q&As Helped to Solve: 774 [?]
Skill Endorsements: 35 [?]
Featured
 
0
 

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 :P

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.

Member Avatar
verruckt24
Posting Shark
945 posts since Nov 2008
Reputation Points: 438 [?]
Q&As Helped to Solve: 97 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
masijade
Industrious Poster
4,165 posts since Feb 2006
Reputation Points: 1,351 [?]
Q&As Helped to Solve: 510 [?]
Skill Endorsements: 22 [?]
Team Colleague
Featured
 
0
 

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."

Member Avatar
verruckt24
Posting Shark
945 posts since Nov 2008
Reputation Points: 438 [?]
Q&As Helped to Solve: 97 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
stultuske
Posting Expert
5,290 posts since Jan 2007
Reputation Points: 935 [?]
Q&As Helped to Solve: 774 [?]
Skill Endorsements: 35 [?]
Featured
 
0
 

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.

Member Avatar
masijade
Industrious Poster
4,165 posts since Feb 2006
Reputation Points: 1,351 [?]
Q&As Helped to Solve: 510 [?]
Skill Endorsements: 22 [?]
Team Colleague
Featured
 
0
 

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.

Member Avatar
verruckt24
Posting Shark
945 posts since Nov 2008
Reputation Points: 438 [?]
Q&As Helped to Solve: 97 [?]
Skill Endorsements: 0 [?]
 
0
 

Okay mistake agreed and apologies to the one's hurt.
Thanks for correcting me.

Member Avatar
jbennet
Moderator
17,127 posts since Apr 2005
Reputation Points: 1,618 [?]
Q&As Helped to Solve: 736 [?]
Skill Endorsements: 38 [?]
Team Colleague
Featured
 
0
 

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

Member Avatar
stultuske
Posting Expert
5,290 posts since Jan 2007
Reputation Points: 935 [?]
Q&As Helped to Solve: 774 [?]
Skill Endorsements: 35 [?]
Featured
 
0
 

??? 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.

I was talking about the windows exe file

Member Avatar
verruckt24
Posting Shark
945 posts since Nov 2008
Reputation Points: 438 [?]
Q&As Helped to Solve: 97 [?]
Skill Endorsements: 0 [?]
 
0
 

??? 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.

Completely agree with you, but I guess Stultuske is mentioning the .exe files over here.

Member Avatar
~s.o.s~
Failure as a human
10,399 posts since Jun 2006
Reputation Points: 2,496 [?]
Q&As Helped to Solve: 992 [?]
Skill Endorsements: 72 [?]
Administrator
Featured
 
0
 

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.

I agree with you when you say that class files shipped as part of your application can be very *easily* decompiled without any kind of special; all you need is a class file decompiler which are pretty easy to get by. On the other hand, decompiling/reverse engineering platform dependent executables and libraries [static and dynamic] is no easy feat and definitely can't be achieved by a casual script kiddie or a curious programmer; it requires much more expertise.

To avoid the ease of decompiling class files, you can use free softwares like ProGuard which shrinks, optimizes and obfuscates the class files.

Come to think of it logically, it is very much an assumed scenario that developing commercial application in Java and distributing them always has the possibility of the application being decompiled. Such applications rely on restrictive licenses stating that any part of the application is a proprietary entity. Examples include IBM Application Servers like Websphere.

Member Avatar
verruckt24
Posting Shark
945 posts since Nov 2008
Reputation Points: 438 [?]
Q&As Helped to Solve: 97 [?]
Skill Endorsements: 0 [?]
 
0
 

On the other hand, decompiling/reverse engineering platform dependent executables and libraries [static and dynamic] is no easy feat and definitely can't be achieved by a casual script kiddie or a curious programmer; it requires much more expertise.

yes thats exactly what I was trying to put through, but I incorrectly qouted myself which obviously did not go down well with some of the members. No issues and I admitted it.
Thanks.

Member Avatar
kazek
Newbie Poster
24 posts since Sep 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

So far the only applications I've found still require that the computer in use has Java installed.

I've only been successful with "exe4j"
Everything else is just too confusing to use especially since they are all trial versions.

Member Avatar
peter_budo
Code tags enforcer
7,933 posts since Dec 2004
Reputation Points: 2,502 [?]
Q&As Helped to Solve: 1,028 [?]
Skill Endorsements: 66 [?]
Moderator
Featured
 
0
 

Did you read this yet? Convert Java to EXE - Why, When, When Not and How

PS: If you so "hot" to get your application in EXE format, why don't you pay for the software. Then you will not deal with trial version and people that spent their time to create these converters get credit where due..

Member Avatar
verruckt24
Posting Shark
945 posts since Nov 2008
Reputation Points: 438 [?]
Q&As Helped to Solve: 97 [?]
Skill Endorsements: 0 [?]
 
0
 

So far the only applications I've found still require that the computer in use has Java installed.

The one I have already pointed out, JexePack, does not require java to be installed, it does install JRE automatically when the target machine does not have it installed and you have told to do it that way.
Also to repeat what I have mentioned you would have to purchase a license for this product.

Member Avatar
shiv53
Newbie Poster
1 post since May 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

write a simple c program in visual studio.

#include <stdlib.h>
#include <process.h>
void main()
{
system("java class_name");
}

Place the exe file and class file in same directory if you are following above code.

Member Avatar
__avd
Posting Genius (adatapost)
6,703 posts since Oct 2008
Reputation Points: 1,811 [?]
Q&As Helped to Solve: 1,272 [?]
Skill Endorsements: 61 [?]
Moderator
 
0
 

If all experts are agree then there is a problem.

-- Unknown.
Great !!! I appreciate your time.

Member Avatar
templa
Newbie Poster
1 post since Jul 2009
Reputation Points: -2 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-1
 

class HelloWorldApp {
public static void main(String[] args) {

System.out.println("Hallo World");

}
}

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article