Creating a java application launch for" narrow-minded " users
There is a jar archive with a java application. You need to make it so that the user can run the application not from the command line, but simply click on the shortcut and everything starts (under Windows). How do I do this? Write and compile a program, for example, in C#, which will make a java-jar app.jar?
6 answers
You can just write a bat file, for example, start. bat, and in it what you wrote java-jar
Creating a runjar.bat file with the following content:
@echo off
@java -jar %*
On windows 7 did this: Start -> Default Programs -> Associate a file type or protocol with a program
For the jar file, specify the path to runjar.to the bat file.
Jar file to check:
META-INF\MANIFEST.MF
HelloWorld.class
Manifest content:
Manifest-Version: 1.0
Class-Path: .
Main-Class: HelloWorld
Java source:
import javax.swing.JFrame ;
public class HelloWorld
{
public static void main ( String[] args )
{
JFrame f = new JFrame ( "Hello world" ) ;
f.setSize ( 200, 200 ) ;
f.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE ) ;
f.setVisible ( true ) ;
}
}
You can even make a shortcut for Java.exe
with the necessary startup parameters. Labels are somehow more aesthetically pleasing than batniki.
Http://www.ucware.com/jexec/
Http://www.regexlab.com/en/jar2exe/
In my opinion, it is more convenient to configure the launch of jar files by means of the system (in Windows - "Properties" - "Change application" -- > "Java Platform binary" (java (w).exe)). As an option. Do not create the same shortcut next to each jar file.
Creating a. reg file, and in it a string for adding the type .the jar to run java.exe with the-jar parameter "%1"
As a result, all jar files will run as needed. Windows is not at hand right now, so I can't tell you the exact solution. But I think if you Google it, you'll find it.