views:

597

answers:

2

Is there a default classpath on Mac OS X 10.6? When I echo $CLASSPATH, nothing would show up. In my .profile, I only see PATH variable being set. My problem is that My servlet cant seem to find a suitable driver to connect to the mysql server. I use Eclipse, with Glassfish v3 and MAMP for MYSQL server.

+3  A: 
Michael Aaron Safyan
the first 2 suggestions are BAD suggestions and the third one is not really an option when working with a Servlet container, you should include the .jar file in the lib directory of the .war you are deploying to your Servlet container.
fuzzy lollipop
you should NOT need to have a CLASSPATH it makes your machine really brittle and rife with .jar conflicts.
fuzzy lollipop
OK, when I develop on Netbean, I can see my War file, but not on eclipse. Does eclipse create war file for deployment? If so where do I put the jar file? inside WEB-INF/lib?
Harry Pham
Aslo when setting the classpath i beleive you need to do so in the users environment.plist (/Users/username/.MacOSX/environment.plist) in addition to or instead of your .bash_profile. Could be worng about that but i seem having to do that with the svn-javahl and its dependencies.
prodigitalson
Sigh...very where I go in the java world, I heard about maven. I looked at it before, quite robust and complex. Is it very important to know maven?
Harry Pham
@Harry, Maven is definitely worth it, though I agree, it is a bit hard to configure.
Michael Aaron Safyan
just tell Eclipse to add the .jar file to the WEB-INF/lib dir, you do not need to deal with Maven if you are building with Eclipse
fuzzy lollipop
A: 

Do not use the CLASSPATH environment variable. This is portability trouble. The whole environment variable is a mistake of the Sun guys. It's only useful for starters, but certainly not in real world. This would only confuse the starters more afterwards. Besides, appservers (and IDE's) completely ignores this environment variable. Do not put the libraries in the library of JRE or JDK. This is portability trouble as well. If you upgrade the JRE/JDK or run the application somewhere else, it won't work anymore.

In webapplications, you normally just drop webapp-specific 3rd party libraries in Webapp/WEB-INF/lib. This folder is covered by the webapp's default classpath. If those libraries are rather appserver-specific (e.g. JDBC driver is required to create a JNDI datasource which is managed by the appserver), then you need to drop them in Appserver/lib. This folder is covered by the appserver's default classpath. In case of Glassfish, you need to put it more specifically in the domain-specific /lib folder, e.g. glassfish/domains/<domainname>/lib.

BalusC