Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAXB jar files incompatible with java 1.6.0?

Tags:

jaxb

I'm new to JAXB and I want to marshal and un-marshal XML/Objects to Objects/XML.

I have downloaded JWSDP 2.0 from (worth 22.69 MB) Sun's site.

I have set Environment variables as

JAVA_HOME :-   D:\Program Files\Java\jdk1.5.0  
JWSDP_HOME :-   D:\Sun\jwsdp-2.0  
JAXB_HOME :- D:\Sun\jwsdp-2.0\jaxb  
PATH :- D:\Program Files\Java\jdk1.5.0\bin;D:\Sun\jwsdp-2.0\jwsdp-shared\bin;  

I'm trying to compile a simple XSD file (named tp.xsd) using XJC (which is present in D:\Sun\jwsdp-2.0\jaxb\bin).

I'm getting the following output when I try to compile it:

D:\Sun\jwsdp-2.0\jaxb\bin>xjc tp.xsd

parsing a schema...  
compiling a schema...  
generated\Bookdata.java  
Exception in thread "main" java.lang.NoSuchMethodError: java.lang.Class.getSimpl
eName()Ljava/lang/String;  
        at com.sun.codemodel.JCodeModel$JReferencedClass.name(JCodeModel.java:54
5)  
        at com.sun.codemodel.JFormatter.t(JFormatter.java:283)  
        at com.sun.codemodel.JClass.generate(JClass.java:358)  
        at com.sun.codemodel.JFormatter.g(JFormatter.java:346)  
        at com.sun.codemodel.JAnnotationUse.generate(JAnnotationUse.java:388)  
        at com.sun.codemodel.JFormatter.g(JFormatter.java:346)  
        at com.sun.codemodel.JDefinedClass.declare(JDefinedClass.java:767)  
        at com.sun.codemodel.JFormatter.d(JFormatter.java:372)   
        at com.sun.codemodel.JFormatter.write(JFormatter.java:402)  
        at com.sun.codemodel.JPackage.build(JPackage.java:434)  
        at com.sun.codemodel.JCodeModel.build(JCodeModel.java:297)  
        at com.sun.codemodel.JCodeModel.build(JCodeModel.java:287)  
        at com.sun.tools.xjc.Driver.run(Driver.java:378)  
        at com.sun.tools.xjc.Driver.run(Driver.java:196)  
        at com.sun.tools.xjc.Driver._main(Driver.java:121)  
        at com.sun.tools.xjc.Driver.access$000(Driver.java:79)  
        at com.sun.tools.xjc.Driver$1.run(Driver.java:101)  

Can you help me finding the solution? I know that the error

Exception in thread "main" java.lang.NoSuchMethodError: java.lang.Class.getSimpl eName()Ljava/lang/String;   

occurs due to compiler and class file incompatibility, but I'm not getting what to do!

When I run java -version command it shows:

C:\Documents and Settings\welcome>java -version  
java version "1.6.0_23"  
Java(TM) SE Runtime Environment (build 1.6.0_23-b05)  
Java HotSpot(TM) Client VM (build 19.0-b09, mixed mode, sharing)  
like image 494
Kunal Avatar asked Dec 06 '25 23:12

Kunal


1 Answers

The jaxb libraries are included in java 1.6. You'll get all kinds of crazy classloader errors if you add the jar too.

In this case, it looks like it xjc picked the wrong version of the jar.

edit

xjc should be bundled in the JDK, in your post you are using the xjc that comes in the jabx stand-alone pack. Go to the folder where you installed java 1.6, check that you have the xjc.exe or xjc.bat there and run it from that folder. And like Robert mentioned above, be sure that you're using Java 1.6

like image 83
Augusto Avatar answered Dec 10 '25 16:12

Augusto



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!