aspose file tools*
The moose likes Beginning Java and the fly likes Could Not Find or Load Main Class error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Could Not Find or Load Main Class error" Watch "Could Not Find or Load Main Class error" New topic
Author

Could Not Find or Load Main Class error

Thomas Yemane
Greenhorn

Joined: Jul 27, 2013
Posts: 3
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

Joined: Aug 07, 2007
Posts: 2289
    
  49
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

Joined: Aug 07, 2007
Posts: 2289
    
  49
And Welcome to the Ranch
Thomas Yemane
Greenhorn

Joined: Jul 27, 2013
Posts: 3
Thanks, here is the whole TryPackage class.

Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2289
    
  49
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

Joined: Aug 07, 2007
Posts: 2289
    
  49
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

Joined: Jul 27, 2013
Posts: 3
Thank you, it executed when I replaced the delimiter like you said!!!
 
Consider Paul's rocket mass heater.
 
subject: Could Not Find or Load Main Class error