• 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

Classpath Confusion

 
Rancher
Posts: 241
Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, I have a classpath problem here.
I'm telnetting to the server on a hosting company that hosts a site I helped design. The JDK is located in /usr/local/java with files like java and javac in the bin subdirectory of this directory. My site is at /home/WWW9/(site name)/ with my .class files, along with some intermediate scripts, in the cgi-bin subdirectory of this directory.
Now here's the thing: I'm in the cgi-bin subdir. If I enter "javac EchoServer.java", the shell compiles it fine. But if I enter "java EchoServer" as the next command, it says "class not found". THEN if I set the -classpath option, to literally anything at all, I will get a different error, "Unable to initialize threads: cannot find class java/lang/Thread".
Anyone know how to fix this?
Thanks
Eric
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a classic problem with Java 1.0 and 1.1. Java 2 fixes it to some degree by locating its system classes through a different method than the CLASSPATH.
Your current directory "." or "/home/WWW9/(site name)/cgi-bin" is not in the default CLASSPATH, but the standard Java classes (rt.jar or classes.zip) are.
When you try to set the CLASSPATH to something else, you are putting your directory in it, but losing the standard java classes. You need to make sure that both your directory and the standard classes (the existing CLASSPATH) are in the CLASSPATH you use to run your classes:
<pre>
CLASSPATH=$CLASSPATH:.
/usr/local/java/bin/java EchoServer
</pre>
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic