How I can run java program using command prompt? I already run my program using command prompt but i get this error Could not find or load main class ReadWriteTextFile
- 
        possible duplicate of Java problem: Could not find main class HelloWorldMcDowell– McDowell2012-12-24 08:56:32 +00:00Commented Dec 24, 2012 at 8:56
2 Answers
Well, there are a few conditions on running a java class:
- First of all, the file you want to run should have a public class, with the same name as the file. For instance, - Test.javawould contain the- Testclass.
- The public class should have a main method. This is a static method. It's arguments are the command line arguments passed. It's signature must be - public static void main(String[] args).
As an example class you can call from the command line:
public class ReadWriteTextFile {
    public static void main(String[] args) {
        readWriteTextFile();
    }
    public static void readWriteTextFile() {
        // Do stuff.
    }
}
If saved in the file ReadWriteTextFile.java, you can compile and call it like this:
$ javac ReadWriteTextFile.java
$ java ReadWriteTextFile
$
Seen from the error message you get, your file is probably called ReadWriteTextFile, but you haven't got a public ReadWriteTextFile class with a main method in it.
4 Comments
main method? That the method called from the command line. It should be something like public static void main(String[] args) { ReadWriteTextFile(); }javac ReadWriteTextFile.java to compile, and java ReadWriteTextFile in order.Check your entry point specification in your manifest as explained here: 
You should set an entry like this one:
Main-Class: YourPackage.ReadWriteTextFile
Maybe the package path is missing? I got myself this kind of issue when launching jar files... I hope this helps.

