3

I know this question has been asked many and many times, but I have done my research and my simple test program still will not run on double click.

When I run the program from the jar (java -jar Test.jar) it will run fine, just double click fails.

I have made a simple class in Eclipse on 64bit Windows 7 Pro, JRE 7 is used and made a Jar file (have tried Runnable)

public class Test {
    public static void main(String[] args){
        System.out.println("nope");
    }
}

Image of basic setup http://i48.tinypic.com/1zh36t2.png

Here is what I have tried (that I remember):

Checked Manifest and made sure class is spelled right and added two extra spaces to end of main class line

Class is included in the jar

Tried Runnable Jar as well as normal Jar

On Normal Jar I included the Main Class Option and selected the class

Checked ftype and typing java in cmd to see if options come up

I have tried other options, but I can't remember them yet.

sl133
  • 1,339
  • 2
  • 15
  • 28
  • start a cmd, try "start xxx.jar". Maybe you can find out what is wrong. – neohope May 06 '12 at 06:01
  • All that does is run the file, which is the same as double clicking the desktop putting me in the same place. If I could find out what was wrong I wouldn't have asked a question. – sl133 May 06 '12 at 06:13
  • Have you added a newline to end the Main-Class line in manifest? And why the two extra spaces, you read somewhere about that? Sounds strange to me. – Marko Topolnik May 06 '12 at 08:28
  • Im not sure if you mean a /n or just a blank line at the end, either way I added both, removed my two spaces and updated the manifest but it still says It cannot find the main class. – sl133 May 06 '12 at 09:15

3 Answers3

1

Sounds like a file association problem to me: you need to make sure Windows is set up to associate .jar files with java.exe in the right way.

See the answers to: Running JAR file on Windows

Community
  • 1
  • 1
mikera
  • 105,238
  • 25
  • 256
  • 415
  • That first answer is for Windows Xp, but I have already reset my file asssociation type to jre7 and I tried that jarfix program which reset it back to jre6, but it still doesn't work anyway. I tried this link as well, and it did not work: http://stackoverflow.com/questions/394616/running-jar-file-in-windows – sl133 May 06 '12 at 05:43
1

I have had issues with having a space in the path name when double clicking to run. When the path had a space in it, the jar would not execute using double click but would using java -jar EscapedPathToJarOrQuotedPathToJar

Chris McKnight
  • 8,540
  • 4
  • 29
  • 31
0

According to my reading of the JAR file specification, there should be exactly one space after the colon, and zero spaces after the classname. Any additional leading or trailing spaces might end up be included in the notional class name, and that could result in the java command failing to find the real entry point class name.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216