• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bug:GhostsFoundInClasspath

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm moving this to Java in General (Beginner).
Corey
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DO
java org.Class3 in u C:\folder3\org\ directory.
[ removed quote -ds ]
[ June 13, 2002: Message edited by: Dirk Schreckmann ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic