jaxp error

A

asd

hi all,

I am using jsdk1.4.2.
My simple application goes like this:

import java.io.*;
import javax.xml.transform;


public class Jax{
public static void main(String args[]) throws
javax.xml.transform.TransformerException{
File xmlFile = new File(args[0]);
System.out.println("Created the file");


javax.xml.transform.Source xmlSource =
new javax.xml.transform.stream.StreamSource(xmlFile);
System.out.println("Created XmlSource");
}
}

and when I compile this file by typing the command javac Jax.java
this is the error that I get.

[root@localhost exp]# javac Jax.java
Jax.java:2: Class or interface `javax.xml.transform' not found in
import.
import javax.xml.transform;
^
Jax.java:5: Class `javax.xml.transform.TransformerException' not found
in `throws'.
public static void main(String args[]) throws
javax.xml.transform.TransformerException{
^
Jax.java:9: Type `javax.xml.transform.Source' not found in the
declaration of the local variable `xmlSource'.
javax.xml.transform.Source xmlSource =
^
3 errors

I opened src.jar and found that javax.xml.transform package is
implemented.

Any idea what is the problem.
Any help will be appreciated.

regards and thanx in advance

asd
 
A

Arnaud Berger

Hi,

In your import statements, you ought to specify either a class name :

e.g import javax.xml.transform.TransformerException;

or the whole package

e.g import javax.xml.transform.*;

Indeed , writing :

import javax.xml.transform;

is considered as the class "transform" from the package javax.xml


Cheers,

Arnaud
 
A

asd

Hi,
Thank you very much for the reply.
sorry for that silly mistake.
I did exactly as you told but still some errors are there.

Now the code is:
import java.io.*;
import javax.xml.transform.*;
//import javax.xml.transform.stream.*;

public class Jax{
public static void main(String args[]) throws TransformerException{
File xmlFile = new File(args[0]);
System.out.println("Created the file");

Source xmlSource = new
javax.xml.transform.stream.StreamSource(xmlFile);
System.out.println("Created XmlSource");
}
}

And on compilation the output is:
[root@localhost exp]# javac Jax.java
Jax.java:6: Class `TransformerException' not found in `throws'.
public static void main(String args[]) throws
TransformerException{
^
Jax.java:10: Type `Source' not found in the declaration of the local
variable `xmlSource'.
Source xmlSource = new
javax.xml.transform.stream.StreamSource(xmlFile);
^
2 errors

Please notice that the compiler can find
"javax.xml.transform.stream.StreamSource" but does not find "Source".

Any help will be greatly appreciated.

regards,
Arvind
 
A

asd

Solved the problem........ it was only because of improperly set
classpath.

regards,
asd
 

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

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,162
Latest member
GertrudeMa
Top