Double-clicking a JAR file does not open a command prompt

I want to run a jar file by double-clicking it.

Below is the only Java class file present in it.

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Sysout{
public static void main(String[] args) throws IOException{
    System.out.println("Hello World!");
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String msg = br.readLine();
    System.out.println(msg);
    br.read();
}
}

And the manifest file has a main class.

Using this link, I successfully executed the Jar file by double-clicking the batch file. This opens the command line and starts the main class.

However, if I double-click the Jar file directly, nothing will happen. I also checked this link and linked my .jar to javaw.exe. This link also offers the same. Also tried to associate .jar with java.exe

It happens that the command line opens for a split second and disappears.

, , , - .

?

+5
2

javaw, System.out System.err.

.jar java, .

Open With..., -jar .

( , Vista Windows 7 UAC) :

assoc .jar=jarfileterm
ftype jarfileterm="C:\Program Files\Java\jre7\bin\java.exe" -jar "%1" %*

C:\Program Files\Java\jre7\bin\java.exe , jre.

, .

ftype:

ftype jarfile="C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %*

javaw , .

-, assoc .jar=jarfileterm assoc .jar=jarfile

.jar, java- cmd /s /k viz:

ftype jarfileterm=cmd /s /k ""C:\Program Files\Java\jre7\bin\java.exe" -jar "%1" %*"
assoc .jar=jarfileterm

, jar .

Open With... Default Programs, jar. ftype assoc , .

regedit .jar HKEY_CLASSES_ROOT - , (Default) , ftype , jarfileterm. , , ( , java updater , , )

HKEY_CLASSES_ROOT. , Shell (.. jarfileterm Shell)), Open, Command, a (Default), .jar . ftype jarfileterm=..., . , cmd /s /k "c:\program\java\jre7\bin\java.exe" ( , )

+13

, .jar , "Java-TM Platform Platform SE binary". , jar.

+1

All Articles