• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot find symbol

 
Tontang Bei
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 classes both in same package (util.DateParse and util.Testit). I try calling a static method of the class DateParse from class Testit class, and it says:

Testit.java:9: cannot find symbol
symbol : variable DateParse
location: class util.Testit
Date d1=DateParse.parseIt(input);
^
1 error

below are the codes for the class

Class DateParse


Class Testit
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure that your CLASSPATH is properly set. If you're compiling in the util directory, you can try "javac -cp . *.java"

public static Date ParseIt(String dateTobeParsed){

You'd better give method names starting with lower-case.
 
Tontang Bei
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thnaks very much Satou. I have fixed the method names and gotten it to compile but when I run it it gives the following exception

C:\jf\util>java Testit
Exception in thread "main" java.lang.NoClassDefFoundError: Testit (wrong name: util/Testit)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

below is the method test() in Testit class


Ive even tried running with java -classpath . Testit and it still doesnt work.
[ May 07, 2007: Message edited by: Tontang Bei ]
 
Tontang Bei
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I got it. I was running from within current package which was mistake.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic