简体   繁体   中英

Run Java applications By double click

why i can`t run my java compiled applications with double click? my applicatins just run in cmd (java -jar: my app.jar) plz help me

You can make a batch file to run your command. This way it will work without the need to make associations to .jar files. If it is a windows app then start it with javaw.exe.

You need to associate the .jar extension with javaw.exe , then no console window will be shown, when you double click the jar file

This is usually done by the JDK/JRE installer, so either you didn't install the JDK properly, or you manually changed that associaten.

I think all the answer here are valid. But if you want a true executable file in Windows then you need to create a launcher. In windows, jar files are not executable. But exe files are. There are many tools out there than wrap all your java code around some native library. I recommend http://launch4j.sourceforge.net/ I think this is what you are looking for. You can easily create executable with icons and many more features.

You can create a Windows shortcut to your .jar file.

The following line could be the target of the Windows shortcut.

%windir%\system32\javaw.exe -Xms1m -Xmx1m -jar "C:\Program Files\Jar Directory\file.jar"

This has the advantage of allowing you to specify the javaw parameters that you want, as well as the Windows parameters (normal window, maximized, start in directory) that you want.

Just assign .jar files to be executed by javaw.exe . You can do that using the Open with dialog on a .jar file.

BTW, doesn't the Java installer do that for you?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM