-1

I am new to Java. I just wanted to make a jar file from a java file and then run the jar file. The jar is created but when I run it, I encounter this error "Could not find or load main class MyTest Caused by: java.lang.ClassNotFoundException: MyTest"

The MyTest.java file was simply something like this:

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class MyTest {
    public static void main(String[] args) {
        ....
    }
}

My Manifest.MF file is like below:

Manifest-Version: 1.0
Main-Class: MyTest

And I created the jar file using jar cmvf Manifest.MF test.jar MyTest.java in command line.

Could anyone please help me?

nsh
  • 15
  • 1
  • 5

1 Answers1

0

This problem can be due a lot of causes.I have had it many times , most of the time it is because your classpath has non-english characters or spaces. Try to change your project to other directory. On the other hand if you use eclipse you may have more than one main and there are problems with that.

If you try what I have told you and still the problem persists, it will be a problem with the command.

Good luck.