To compile I use this:
...it works great since i have the jdom.jar-file in the same directory
(I asume that you can have the jar-file anywhere you want, as long as
the path is correct).
Good. Right.
But when I run the program I get this:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/jdom/Element
at example1.main(example1.java:7)
...why wont this work???
You have to have the classpath stuff up front ...
java -classpath $CLASSPATH example1
GIMME, when you are talking about the CLASSPATH do you mean the
enviroment variable (NOTE: Im using windows here, not linux)???
Yes. Although the syntax of separaters differ, back slashes instead
of forward slashes, in each instance you want an environment variable.
I have
tryed "set CLASSPATH ..." but its still the same problem.
Try :
echo %CLASSPATH%
Relying on Window's environmental variables all the time can
lead to some undesirable behavior.
I use a dos batch script to set up my environmental variables
and then call cygwin. Here a sample script for you to study.
If you don't have cygwin installed delete or comment out the last
line.
@echo off
set PROOT=C:\Project\WEBELocal\Vignette\Portal
set JAVA_HOME=C:\Apps\jdk1.3.1_07
set JARS=C:\Project\WEBELocal\Vignette\Portal\portal\WEB-INF\lib
set CLASSES=C:\Project\WEBELocal\Vignette\Portal\portal\WEB-INF\classes
set CLASSPATH=.
set CLASSPATH=%CLASSPATH%;C:\bin
set CLASSPATH=%CLASSPATH%;%CLASSES%
set CLASSPATH=%CLASSPATH%;%JARS%\epicentric.jar
set CLASSPATH=%CLASSPATH%;%JARS%\bsf.jar
set CLASSPATH=%CLASSPATH%;%JARS%\bsfengines.jar
set CLASSPATH=%CLASSPATH%;%JARS%\collections.jar
set CLASSPATH=%CLASSPATH%;%JARS%\cos.jar
set ANT_HOME=%PROOT%\samples\cartool\jakarta-ant-1.5
C:\WINDOWS\system32\COMMAND.COM /E:4096 /c C:\cygwin\cygwin.bat