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 Bug:GhostsFoundInClasspath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Bug:GhostsFoundInClasspath" Watch "Bug:GhostsFoundInClasspath" New topic


jyothi abraham
Ranch Hand

Joined: Aug 14, 2001
Posts: 46
Please somebody explain to me on classpath on following:
1)I have following files;
(Class2 extends from Class1)
2)Class3 file contains following lines;
package org;
import com.Class2;
class Class3{
public static void main(String args]{
When I am compiling from C:\folder3\org>:
javac -classpath %path;C:\folder2,it
compiles fine.
a)when I am running from same directory
java Class3
it produces an error:NoClassDefintionFound
but when I comment out package line it works
b)javac -classpath %path;C:\folder1;C:\folder2;
C:\folder3 produces an error,can't
read it happens while
import com.Class2; statement of Class3 in the same directory compiles without a problem?
In all, what modifications I have to make to compile and run in same directory.It now appears
to me like a ghost story
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
I'm moving this to Java in General (Beginner).

SCJP Tipline, etc.
timothy zimmerman
Ranch Hand

Joined: Jun 26, 2001
Posts: 149
I am not sure I am correct but I think you may have better luck if you redirect the output of the compile to a common directory using the javac -d option.
javac -d c:\build\classes c:\folder1\com\*.java c:\folder2\com\*.java c:\folder3\org\*.java
Then to execute:
java -classpath c:\build\classes;%CLASSPATH% org.Class3
The advantage of having a common build area (ie build/classes) is that you can put that directory in your classpath and the package structure will be built up from that (ie build/classes/com build/classes/org).
to address what I can in your post
a)java Class3 does not provide a CLASPSATH so you must have the directory containing your compiled package for Class2 in your environment
b) not sure I entirely understand but if you provide more detail I will try again.
Hope this was helpful
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

java org.Class3 in u C:\folder3\org\ directory.
[ removed quote -ds ]
[ June 13, 2002: Message edited by: Dirk Schreckmann ]

I agree. Here's the link:
subject: Bug:GhostsFoundInClasspath
It's not a secret anymore!