I'm trying to run a simple code in java by command prompt. I have a jar.java file containing this :
public class jar{
public void print()
{
System.out.println("Jar success accesing !");
}}
and also i have a main.java that call use jar class:
public class main{
public static void main (String args[]){
jar jar1 = new jar();
jar1.print();
}}
I just tried to compile jar.java and then make it an jar archive, and then compile main class using this jar like here :
>javac jar.java
>jar cvf JAR.jar jar.class
>javac -cp JAR.jar main.java
Now, until here all works fine bun when i want to run main it doesn't work:
>java -cp JAR.jar main
and i get this :
Error: Could not find or load main class main.class
Caused by: java.lang.ClassNotFoundException: main.class
Where i am wrong ?