In order to make the command double-clickable, you have two options.
The first is a bat file with exactly that string "java -jar application.jar" in it, which is double-clickable just like exe.
The second is to make an exe by compiling the following C program.
int main(){
system("java -jar application.jar");
}
Answer from merlin2011 on Stack OverflowIn order to make the command double-clickable, you have two options.
The first is a bat file with exactly that string "java -jar application.jar" in it, which is double-clickable just like exe.
The second is to make an exe by compiling the following C program.
int main(){
system("java -jar application.jar");
}
I like to use 7zsd.sfx to create installers for my java applications.
Directions:
1.) install 7zsd.sfx from http://7zsfx.info/en/ and install 7z
2.) create a .7z archive
3.) add all the jre files required to run the java application to the archive
4.) add the application itself to the archive
5.) add a .bat or .exe file (for windows) to install the files after 7zsd.sfx extracts all the files
6.) add a .bat or .exe file to run the java application using the jre files
7.) create a file (preferably named "app.tag") with a structure such as that below (add your own parameters)
;!@Install@!UTF-8!
Title="My App"
BeginPrompt="Do you want to install My App?"
Progress="yes"
ExtractDialogText="Please wait while app files are being extracted..."
GUIFlags="32"
ExtractTitle="Installation"
FinishMessage="My app has been installed and added to your desktop."
RunProgram="setup.bat"
;!@InstallEnd@!
The RunProgram is the program that runs after the files are extracted to a temporary folder. This program should create a permanent folder to hold the necessary extracted files (jre, java application, and executable to run app with jre). Additionally, the program should create a nice, good-looking shortcut for the executable file used to run the app and it should move it to the desktop and add an icon.
Finally, to create the exe which will install your files, go to the command line and access the folder with 7zsd.sfx and type in the following command:
copy /b 7zSD.sfx + [pathToDirectory]\app.tag + [pathToDirectory]\yourAppArchive.7z [pathToDirectory]myExeInstaller.exe
What are good exe wrappers/alternatives?
Compiling a java program into an executable - Stack Overflow
Create Exe Wrapper/Installer for my Java App with a custom bundled JRE from Jlink
java - How to pass a system property using Wrapper.exe - Stack Overflow
Videos
I am trying to figure out the best way to distribute a piece of software I have created in Java and .jar is not cutting it for me due to the fact you need to run it from command line. I don't know how to edit manifest files quite yet either. If that is simple then so be it I'll learn it, but an exe wrapper for Windows would be awesome to have.
Another question I have is what is required for people to run my Java program? Do they also need JDK? Do they need JRE installed (if so is this included in the basic Java install 90% of people have) ?
Sorry if this is a little lack luster.
EDIT: another problem has been posed to me: Made a .jar which included my lib folder (aka just for all my packages used) and it worked when I double clicked it and got super excited I went to show my friend. He transferred it to his computer and it’s default program to open was winRAR archiver (WTF) and so he could not run the .jar and rather just extracted files. Is there a fix or am I SOL?
You can convert .jar file to .exe on these ways:

(source: viralpatel.net)
1- JSmooth .exe wrapper:
JSmooth is a Java Executable Wrapper. It creates native Windows launchers (standard .exe) for your java applications. It makes java deployment much smoother and user-friendly, as it is able to find any installed Java VM by itself. When no VM is available, the wrapper can automatically download and install a suitable JVM, or simply display a message or redirect the user to a web site.
JSmooth provides a variety of wrappers for your java application, each of them having their own behaviour: Choose your flavour!
Download: http://jsmooth.sourceforge.net/
2- JarToExe 1.8
Jar2Exe is a tool to convert jar files into exe files.
Following are the main features as describe in their website:
- Can generate “Console”, “Windows GUI”, “Windows Service” three types of exe files.
- Generated exe files can add program icons and version information.
- Generated exe files can encrypt and protect java programs, no temporary files will be generated when program runs.
- Generated exe files provide system tray icon support.
- Generated exe files provide record system event log support.
- Generated windows service exe files are able to install/uninstall itself, and support service pause/continue.
- New release of x64 version, can create 64 bits executives. (May 18, 2008)
- Both wizard mode and command line mode supported. (May 18, 2008)
Download: http://www.brothersoft.com/jartoexe-75019.html
3- Executor
Package your Java application as a jar, and Executor will turn the jar into a Windows exe file, indistinguishable from a native application. Simply double-clicking the exe file will invoke the Java Runtime Environment and launch your application.
Download: http://mpowers.net/executor/
EDIT: The above link is broken, but here is the page (with working download) from the Internet Archive. http://web.archive.org/web/20090316092154/http://mpowers.net/executor/
4- Advanced Installer
Advanced Installer lets you create Windows MSI installs in minutes. This also has Windows Vista support and also helps to create MSI packages in other languages.
Download: http://www.advancedinstaller.com/
Let me know other tools that you have used to convert JAR to EXE.
I would use GCJ (GNU Compiler for Java) in your situation. It's an AOT (ahead of time) compiler for Java, much like GCC is for C. Instead of interpreting code, or generating intermediate java code to be run at a later time by the Java VM, it generates machine code.
GCJ is available on almost any Linux system through its respective package manager (if available). After installation, the GCJ compiler should be added to the path so that it can be invoked through the terminal. If you're using Windows, you can download and install GCJ through Cygwin or MinGW.
I would strongly recommend, however, that you rewrite your source for another language that is meant to be compiled, such as C++. Java is meant to be a portable, interpreted language. Compiling it to machine code is completely against what the language was developed for.
http://wrapper.tanukisoftware.org/doc/english/prop-java-additional-n.html
You can set "additional parameters" that will go to the JVM (as opposed to your main class), and -DADMIN_USERNAME=gandalf should work there.
wrapper.java.additional.1=-Xrs
wrapper.java.additional.2=-Dprop=TRUE
wrapper.java.additional.3=-DADMIN_USERNAME=gandalf
Update: You must start with additional.1 and count up without gaps (This is a convention for shoe-horning lists into Java properties syntax).
You can set certain properties in the wrapper config file, see this link:
http://wrapper.tanukisoftware.org/doc/english/properties.html
I believe you can also configure the wrapper to startup java and pass additional properties using the java "-Dproperty=value" syntax
unhillbilly has a good point. But actually it's not the real reason for the error you are seeing. Basically the manifest file in your jar file appears incorrect.
When you created the jar file, you were probably exporting your project from eclipse as runnable jar and selected as library handling to package the required jar files into the generated jar...
So by doing this Eclipse is using the class JarRsrcLoader.
This class is in fact the main class of your executable jar and not as you might thought your main class.
JarRsrcLoader requires 2 parameters being set in the manifest file: Rsrc-Main-Class and Rsrc-Class-Path.
Rsrc-Main-Class is the class name of your actual main class.
Rsrc-Class-Path is the class path (with all included jar files in the jar file) to launch your application.
Your manifest file appears to miss those 2 properties.
So you can resolve this by changing the way how you are exporting the jar file, for instance use "extract required libraries in jar". Another option would be to add the 2 missing properties into your META-INF/manifest.mf file.
Is a value missing for the port option? You say that your jar is run as:
java -jar smpp-portal -port 90
However, the wrapper config doesn't seem to have the port number as an application parameter:
# Application parameters. Add parameters as needed starting from 1
wrapper.app.parameter.1=../lib/smpp-portal.jar
wrapper.app.parameter.2=-port