views:

80

answers:

1

I got "cannot access org.exolab.castor.core.exceptions.CastorException" from the compiler when I try to use Marshal and unmarshal. I used Castor 1.3

    try {

        Writer writer = new FileWriter("out.xml");
        Marshaller.marshal(person, writer);
        Reader reader = new FileReader("out.xml");
        metaType = (Person) Unmarshaller.unmarshal(Person.class, reader);

    }catch (MarshalException e) {
    } catch (ValidationException e) {
    }
+4  A: 

First of all, this is not an exception, this is a compilation error. The code isn't even able to become a runnable .class file. That's a huge difference. In the future you should try to be more explicit about that.

This compilation error actually means that the mentioned class is missing in the classpath during compiletime. If you're compiling using javac, then you need to add the full path to the Castor JAR file which includes the mentioned class to the -cp (classpath) argument. Something like this:

javac -cp .;c:/path/to/Castor.jar com/example/YourClass.java

That was a Windows Example; in Unix/Linux and clones you need : as path separator. Individual paths with spaces inside should be enclosed by quotes.

BalusC
i run the file from jdeveloper, how do i add in the path?
Check the *Libraries* section in the project properties.
BalusC