LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   java - package does not exist error (http://www.linuxquestions.org/questions/programming-9/java-package-does-not-exist-error-559202/)

epoo 06-04-2007 10:41 PM

java - package does not exist error
 
I'm trying to compile a program I'm writing using a file for one of the classes.

here's my file menu.java:
Code:

public class menu
{ void storage()
  {  System.out.println("storage");
  }
}

and here's the java file with the main method:

Code:

import menu.*;
public class test
{  menu menu1 = new menu();
  public static void main(String[] args)
  { System.out.println("test");
  }
}

and I'm getting the error

Code:

test.java:1: package menu does not exist
I've exported the classpath, "echo $CLASSPATH" shows ":/home/epoo/game/:./"

Any ideas?

paulsm4 06-04-2007 11:53 PM

Just comment out the "import menu.*", recompile - and Life should be Good

Here's a very good tutorial that explains the relationship between "package", "import statements" ... and how you need to put your class files in different subdirectories if you decide you need to use packages:

http://www.jarticles.com/package/package_eng.html

epoo 06-05-2007 12:21 AM

Ahh, I see. That worked, thanks.
I'm having a hard time understanding the difference between static and non-static methods and variables - got any good tutorials for that ?


All times are GMT -5. The time now is 09:59 PM.