File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes cannot find symbol Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "cannot find symbol" Watch "cannot find symbol" New topic

cannot find symbol

Tontang Bei
Ranch Hand

Joined: Oct 21, 2006
Posts: 130
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: 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é

Joined: Nov 24, 2005
Posts: 14688

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.

[My Blog]
All roads lead to JavaRanch
Tontang Bei
Ranch Hand

Joined: Oct 21, 2006
Posts: 130
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 Source)
at Source)
at$100(Unknown Source)
at$ Source)
at Method)
at 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

Joined: Oct 21, 2006
Posts: 130
Ok I got it. I was running from within current package which was mistake.
I agree. Here's the link:
subject: cannot find symbol
jQuery in Action, 3rd edition