help getting castor to work

P

plusGForce

I have the following problem trying to get castor to work. When I
compile a
program called castor, I get the error message "org.exolab.castor.xml
does not exist".

REM setJava.bat
set JAVA_BASE=C:\users\office\Desktop\Javalib\castor-1.2
set JAVA_HOME="C:\Program Files\Java"
set XERCES_HOME=%JAVA_BASE%\lib\xerces-J_1.4.0
set CASTOR_HOME=%JAVA_BASE%\castor-1.2
set CASTOR_CLASSES=%CASTOR_HOME%\lib\castor-1.2.jar;%CASTOR_HOME%\lib
\castor-1.2-xml.jar;%CASTOR_HOME%\lib\xerces-J_1.4.0.jar;%CASTOR_HOME%
\lib\commons-logging-1.1.jar;
-------------------------------------------------------
package mypackage1;
import java.io.StringReader;
import org.exolab.castor.xml.MarshalException;
.....

public class Tester {

public static void main(String[] args) {
String xml = "<DataBean><value1>foo</value1></DataBean>";
StringReader sr = new StringReader(xml);
InputSource is = new InputSource(sr);
Unmarshaller um = new Unmarshaller();
try {
DataBean dataBean = (DataBean)um.unmarshal(DataBean.class,
is);
System.out.println("value1 is " + dataBean.getValue1());
}
catch (MarshalException e) {
e.printStackTrace();
}
catch (ValidationException e) {
e.printStackTrace();
}
}
}

How do I make my windows system recognize the castor libraries?

Thanks.
 
L

Lew

plusGForce said:
I have the following problem trying to get castor to work. When I
compile a
program called castor, I get the error message "org.exolab.castor.xml
does not exist".

REM setJava.bat
set JAVA_BASE=C:\users\office\Desktop\Javalib\castor-1.2
set JAVA_HOME="C:\Program Files\Java"
set XERCES_HOME=%JAVA_BASE%\lib\xerces-J_1.4.0
set CASTOR_HOME=%JAVA_BASE%\castor-1.2
set CASTOR_CLASSES=%CASTOR_HOME%\lib\castor-1.2.jar;%CASTOR_HOME%\lib
\castor-1.2-xml.jar;%CASTOR_HOME%\lib\xerces-J_1.4.0.jar;%CASTOR_HOME%
\lib\commons-logging-1.1.jar;
-------------------------------------------------------
package mypackage1;
import java.io.StringReader;
import org.exolab.castor.xml.MarshalException;
.....

public class Tester {

public static void main(String[] args) {
String xml = "<DataBean><value1>foo</value1></DataBean>";
StringReader sr = new StringReader(xml);
InputSource is = new InputSource(sr);
Unmarshaller um = new Unmarshaller();
try {
DataBean dataBean = (DataBean)um.unmarshal(DataBean.class,
is);
System.out.println("value1 is " + dataBean.getValue1());
}
catch (MarshalException e) {
e.printStackTrace();
}
catch (ValidationException e) {
e.printStackTrace();
}
}
}

How do I make my windows system recognize the castor libraries?

javac -cp %CASTOR_CLASSES%;%OTHER_CLASSPATH_ELEMENTS% mypackage1/Tester.java

or

javac -cp %CASTOR_HOME%/lib/*;%OTHER_CLASSPATH_ELEMENTS% mypackage1\Tester.java

(all on one line, of course)

RTFM:
<http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top