Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CLASSPATH hassles....or is it???

 
Hilton Meyer
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm wondering whether its just me or if others have had trouble with this. I've searched the Interent and came up with complicated answer's. I'm trying to go through a JavaMail&James tutorial but I can't even set up the JavaMail API. I try to Set the CLASSPATH which seems to work because when I "echo %CLASSPATH" it comes back with the results that I input. Once I compile the program however the compiler tells me that: package javax.mail does not exist. I'm not sure whether its the setup problem or something else. I've placed the unziped folder of JavaMail into a folder called C:\JAMES_HOME\javamail-1.4ea. After this I added the mail.jar to the CLASSPATH like this: set CLASSPATH=%CLASSPATH%;c:\JAMES_HOME\javamail-1.4ea\mail.jar;. I have two questions:
1)Is the JavaMail API setup in the CLASSPATH and can I use it like this?
2)Is the compile error connected to this problem?

Here is the code of the program:

[ January 25, 2006: Message edited by: Hilton Meyer ]
 
Hilton Meyer
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved the problem by copying the jar's into the jre/ext file. I would still like to know if there are other solutions.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hilton,
You should not have to place external jars in this directory.

What command are you using to compile the source ?
 
Hilton Meyer
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to use the javac command but the system said that this was not recognised. After reading a bit further in the article they suggested copying the jar's into the folder. It's no the best solution but it solved the problem for now. I would still like a solution so that in future I would not run into this problem.
 
Kamesh Loganathan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pal,
If u get a message saying command not recognised when u type javac
then u have to set the PATH variable to the bin folder of java.

Letz say u have java in C:

then use set path=c:\j2sdk1.4.2\bin;.;%path%

After this set the classpath to the jars and try compiling.It should work
 
Hilton Meyer
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to evryone,

I fixed the problem by set the variables permanently in the Enviroment Variables in System Settings. Evrytime I was setting the paths up they would work but once I closed the command prompt window they would be reset to null. I'm not sure if I was doing it incorrectly but now they are permanently set up so there's no more hassles.

Thank you very much
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not that you were doing incorrectly. However, you were not doing it permanently. It's good to hear that you got it working. Good luck with your programming project.

Layne
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you use SET in a command prompt it only affects that session.
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Hilton Meyer:
I solved the problem by copying the jar's into the jre/ext file. I would still like to know if there are other solutions.


I work on a J2SE implementation for my day job. A colleague recently proclaimed "do not put *anything* in jre/lib/ext unless you *really* know what you are doing". This is extremely useful advice - the amount of issues I have seen...

In any case, sounds to me like you simply need to use the -classpath switch.
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

A colleague recently proclaimed "do not put *anything* in jre/lib/ext unless you *really* know what you are doing".


I had some problems with placing jar here(jre/lib/ext). When I was learning JNDI I placed certain jars in ext but still I had to include them to classpath to get it working.


File System Service Provider for the
Java Naming and Directory InterfaceTM (JNDI) 1.2
Optional Package

Software Installation

If you are installing the file system provider as an installed extension, copy fscontext.jar and providerutil.jar from the lib directory to the $JAVA_HOME/jre/lib/ext directory


I like to know why didn't the JRE pick those jar files.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic