Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The old "Java Could not find Main Class" Error

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.

like image 842
sl133 Avatar asked Dec 05 '25 15:12

sl133


1 Answers

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

like image 144
mikera Avatar answered Dec 08 '25 08:12

mikera



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!