• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

windows 2000 class path error

 
Dean Reedy
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following setup:

java installed to: c:\j2sdk1.4.1_02
I want to be able to run java programs on an e: drive, but I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: TestMail
I can compile a program for example in the e:\startup folder by typing: c:\j2sdk1.4.1_02\bin\javac TestMail.java from the e:startup folder
However when I go to run this program by typing: c:\j2sdk1.4.1_02\bin\javac TestMail , I get the above error.
Now my envirnoment variable setting are:
Path
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program
Files\Symantec\pcAnywhere\;C:\j2sdk1.4.1_02\bin;
CLASSPATH:
%JAVA_HOME%\lib\tools.jar
JAVA_HOME:
c:\j2sdk1.4.1_02

I would like to be able to compile and run java programs from anywhere on my system. How would I set the classpath to allows this?

Listing on the imports on the testmail program:
import java.sql.*;
import java.text.*;
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.net.InetAddress;
import java.net.*;
public class TestMail
Any help would be great.
thanks!
Dean
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dean Reedy:

I would like to be able to compile and run java programs from anywhere on my system. How would I set the classpath to allows this?

Add the current directory ('.') to the CLASSPATH. That way, no matter what directory you're in, you have that directory in your classpath.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and note that a semicolon is used to separate locations on Windows. So, you probably want your CLASSPATH environment variable value to be similar to the following.
.;%JAVA_HOME%\lib\tools.jar
 
Dean Reedy
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou every for your responses. I did add the "." to the CLASSPATH variable and this allows me to compile and run from the directory with ease. However my orginal problem of the main not found ended up being that my "jar" files needed for the import were in the "c:\j2sdk1.4.1_02\jre\lib\ext\" and that was fine for compiling, but the run the program my "jars" needed to be in the "c:\program Files\java\j2sdk1.4.1_02\jre\lib\ext\" directory.
thanks again.
Dean
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic