December 28th, 2013, 02:48 PM
How do you convert a .java to a .exe file?
I been making GUIs in java and I love it. But obviously when I double click the .java file the compiler opens up. I know I can run it in the command prompt, but I'd rather setup a desktop icon so I can double-click and open.
I'm guessing I need to download a different program other than a compiler, right?
If this is a compiler question I apologize, though the compiler I use is jGRASP. I looked through their help files and only seem to find information on running/compiling it, not converting it to a .exe file.
December 28th, 2013, 03:09 PM
Normally java class files are packaged in a jar file which can be executed on many different OS.
December 28th, 2013, 04:18 PM
Okay I think my compiler does have the jar feature, I just have to select the .class file rather than the .java, and it would only be 1.
But my issue isn't executing it. My issue is changing it to a .exe file so I can open it by mouse-click rather than opening it by opening a compiler 1st or going to a command prompt.
December 28th, 2013, 04:21 PM
I execute jar files by double clicking on them. The JRE installation should establish that connection and mechanism.
December 28th, 2013, 04:34 PM
Okay damn, my next question is how do I convert to a .jar file.
In my compiler, I see there's a "Jar / Zip extractor"
I can "File, Open Jar or Zip file"
I don't see 1 to begin with.
There is a "Create Jar or Zip file for project" but it is not clickable.
It was clickable when I had a bunch of multiple files open, but I closed them all, because what I want executed is 1 file only. I'm guessing I can't if I only want to build 1 file?
December 28th, 2013, 04:37 PM
There should not be a problem creating a jar file with only one class file in it.
I use the jar command in a batch file to create my jar files. No IDE involved.
December 28th, 2013, 04:44 PM
Meh, do I convert the .java file or the .class file into the .jar file?
Does it have to be a project? Or in a project?
December 28th, 2013, 04:49 PM
A jar file is like a zip file, it contains other files. The jar command is used to create the jar file and to put other files, like class files, into the jar file.
If you are using an IDE there may be a project involved. I don't use an IDE and don't know what they require.
If you are using an IDE you need to read its doc to see how to use it to create a jar file.
December 28th, 2013, 04:56 PM
To do this without the compiler, I'd ask what the jar syntax is (like jar class1 class2 file.jar), but my command prompt doesn't recognize jar as a command.
As with the compiler, I'll look into that.
I guess I should be coding GUIs in C++. I guess most .exe's are coded in C++.
December 28th, 2013, 04:59 PM
The jar command is in the SDK's bin folder with the javac command.
December 28th, 2013, 05:47 PM
FWIW, I think a clarification is in place with all those terminologies flying around, some more correct than others. Hope it is useful "as is"
This is what we call an IDE which is a mainly a code editor with a more easier/direct/integrated access to the compiler. It can also contain several other kind of functionalities.
compiler / JDK
Java SDK (aka JDK) is the "development kit" which contains the tools (among others) to compile Java files into class files as well as placing classes into a Jar file.
- To compile source code files with the command line you will use the program "javac".
- To "collect" classes into a jar file, you will call the program "jar" (also by using the command line).
This is the Java Runtime Execution having the program "java" which is used to run the class and/or jar files.
It is also part of the JDK installation.
It is possible to make GUI with C++, although this language can be a bit harder to learn.
Originally Posted by LostShadow
C# (.NET) also makes exe files and can feel more similar to Java. Just note that to run this kind of program it requires the .NET Framework to be installed on the computer
Comments on this post
December 29th, 2013, 10:22 AM
Okay, my next question would be how to convert it to a .jar file without using an IDE since that's what the people here specialize in.
Originally Posted by NormR
I guess I need to download a JRE then. I just recall downloading a Java SE to go with the jGRASP IDE.
Originally Posted by NormR
December 29th, 2013, 11:06 AM
December 30th, 2013, 03:36 PM
Where do I use the jar command, in the command prompt? In the java file?
I don't have Oracle, but I do have Microsoft Access, do I download Oracle?
I see the java.util.jar package, so that makes me think I have to have that in the code.
http://docs.oracle.com/javase/tutorial/deployment/jar/build.html This page talks about the jar command and I think it's referring to a place like the command prompt.
Prior to downloading Java SE, I could not use javac in the command prompt, nor could I build or compile in the IDE.
I had to download Java SE, and surprisingly, I could still not use the javac command (but the java command works), but I could build or compile.
Of course if I can't javac in the command prompt I have other issues, but I'd like to be able to use the jar command also.
However, I presume the Java SE I downloaded included the java.util.jar package or library so I might be having some registry issues. I'm using Windows 7.
December 30th, 2013, 03:47 PM
The javac and jar commands come with the java SDK.
Yes or in a batch file.
You need the java SDK