Reputation: 1
/home/thiru/VS Code Files/Java Files
├── F
│ ├── test.class
│ └── test.java
└── G
├── c.class
└── c.java
c.java imports F package and has main function
When I use javac and java :
:~/VS Code Files/Java Files/G$ javac -cp /home/thiru/VS\ Code\ Files/Java\ Files/ c.java
:~/VS Code Files/Java Files/G$ java -cp /home/thiru/VS\ Code\ Files/Java\ Files/ c
Error: Could not find or load main class c
Caused by: java.lang.ClassNotFoundException: c
When I simply use java command :
:~/VS Code Files/Java Files/G$ java -cp /home/thiru/VS\ Code\ Files/Java\ Files/ c.java
Thirumal
package F;
public class test{
public static void d(){
System.out.println("Thirumal");
}
}
import F.test;
public class c{
public static void main(String[] args){
test.d();
}
}
What's the difference?
Upvotes: 0
Views: 59