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?

Author: Виталий Кустов, 2012-02-01

6 answers

You can just write a bat file, for example, start. bat, and in it what you wrote java-jar .jar

 3
Author: dude, 2012-02-01 07:49:15

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 ) ;
    }
}
 4
Author: jmu, 2012-02-02 13:13:42

You can even make a shortcut for Java.exe with the necessary startup parameters. Labels are somehow more aesthetically pleasing than batniki.

 2
Author: Nofate, 2012-02-01 07:51:26

Http://www.ucware.com/jexec/

Http://www.regexlab.com/en/jar2exe/

 1
Author: nosf, 2012-02-01 11:44:24

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.

 0
Author: Selden, 2012-02-01 10:05:10

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.

 0
Author: Alex Kapustin, 2012-02-03 10:07:21