Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Could Not Find or Load Main Class error

 
Thomas Yemane
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have been trying to learn java recently. I created a package with two classes and a third class in another folder. The third class practically uses the other 2 classes. I was able to compile all the classes using the classpath option on the command line. But when i try to execute the third class i get an error "could not find or load main class".

first class :
package Geometry;
import static java.lang.Math.sqrt;
public class Point{

second class
package Geometry;
public class Line{

third class
import Geometry.*;
public class TryPackage{

micael@ubuntu:~/Documents/java/TryPackage$ javac -cp "/home/micael/Documents/java" TryPackage.java
micael@ubuntu:~/Documents/java/TryPackage$ java -cp ".;/home/micael/Documents/java" TryPackage
Error: Could not find or load main class TryPackage

please Help!!





 
Tony Docherty
Bartender
Posts: 2953
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show the whole of the TryPackage class or at the very least the declaration of the public static void main(String[] args) method
 
Tony Docherty
Bartender
Posts: 2953
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And Welcome to the Ranch
 
Thomas Yemane
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, here is the whole TryPackage class.

 
Tony Docherty
Bartender
Posts: 2953
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags (← click) when posting code as it makes it easier for people to read your code. I've added them for you this time.
 
Tony Docherty
Bartender
Posts: 2953
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just noticed your on a linux platform so the delimiter character in your classpath should be a colon and not a semi-colon.
 
Thomas Yemane
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, it executed when I replaced the delimiter like you said!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic