wood burning stoves 2.0*
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
Author

Bug:GhostsFoundInClasspath

jyothi abraham
Ranch Hand

Joined: Aug 14, 2001
Posts: 46
Please somebody explain to me on classpath on following:
1)I have following files;
i)C:\folder1\com\Class1.java
ii)C:\folder2\com\Class2.java
(Class2 extends from Class1)
iii)C:\folder3\org\Class3.java
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 Class3.java,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
fine.How?
b)javac -classpath %path;C:\folder1;C:\folder2;
C:\folder3 Class2.java produces an error,can't
read Class2.java.Why 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).
Corey


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.
example:
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: 8919

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

Groovy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bug:GhostsFoundInClasspath