This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes CLASSPATH hassles....or is it??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "CLASSPATH hassles....or is it???" Watch "CLASSPATH hassles....or is it???" New topic
Author

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

Hilton Meyer
Greenhorn

Joined: Nov 13, 2003
Posts: 17
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 ]

Keep it Tidy
Hilton Meyer
Greenhorn

Joined: Nov 13, 2003
Posts: 17
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

Hilton,
You should not have to place external jars in this directory.

What command are you using to compile the source ?


[My Blog]
All roads lead to JavaRanch
Hilton Meyer
Greenhorn

Joined: Nov 13, 2003
Posts: 17
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

Joined: Jan 21, 2006
Posts: 20
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

Joined: Nov 13, 2003
Posts: 17
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

Joined: Dec 06, 2001
Posts: 3061
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


Java API Documentation
The Java Tutorial
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
When you use SET in a command prompt it only affects that session.
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
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.


Tony Morris
Java Q&A (FAQ, Trivia)
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026

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.


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: CLASSPATH hassles....or is it???
 
Similar Threads
Getting exception in sending Email from Servlet
Java mail attachmetnt include txt extensions
javamail.providers
urgent help in java mail
AuthenticationFailedException