• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

windows 2000 class path error

 
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
 
Bartender
Posts: 1840
Eclipse IDE Ruby Java
  • 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.
 
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
 
Arthur, where are your pants? Check under this tiny ad.
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!