An example of what a
java
command should look like:
java -Xmx100m com.acme.example.ListUsers fred joe bert
The above is going to cause the
java
command to do the following:
- Search for the compiled version of the
class.com.acme.example.ListUsers
- Load the class.
- Check that the class has a
method with signature, return type and modifiers given bymain
. (Note, the method argument's name is NOT part of the signature.)public static void main(String[])
- Call that method passing it the command line arguments ("fred", "joe", "bert") as a
.String[]
Q1. javac: file not found: polymorphism.music.Music.java
A1: instead use
$ javac polymorphism/music/Music.java
also use absolute classpath, for example,
javac ~/user/polymorphism/music/Music.java
Q2: Error: Could not find or load main class polymorphism.music.Music
A1: be sure already has Music.class, then use
$ java polymorphism.music.Music
or
java polymorphism/music/Music
If you want use javac/java in current directory, you need modify source code. Remove package sentences and some comments in exmaples code.
refereces:
1. https://stackoverflow.com/questions/18093928/what-does-could-not-find-or-load-main-class-mean