users@jaxb.java.net

Solution to various problems running the JAXB examples on Windows with IDE's

From: Laura Ferguson <allenderl_at_ACM.ORG>
Date: Thu, 15 May 2003 15:25:02 -0400

Thanks to everybody who emailed me back about
java.lang.NoClassDefFoundError. It turned out there was more than one
problem with my setup, and I've posted a complete solution at
http://forum.java.sun.com/thread.jsp?forum=34&thread=332451&message=1742079#1742079.

The problems were twofold
        1) If you have an IDE installed (such as Metrowerks), it puts all sorts of
Java libraries in your path. Since these libraries may not have the right
versions of various files it can cause interference.
        2) If you insist on installing software into the Program Files folder (as
I do) than you are going to run into problems with quoting.

Here is my solution to both of these problems:

[This solution worked under Windows 2000 with jwsdp and Java installed in
the Program Files directory.]

---------------------------
If you use Metrowerks or any other IDE which has its own Java versions, in
your batch file reset your PATH variable so it doesn't have all that extra
stuff.

A) When installing/reinstalling jwsdp-1.1, carefully read the directions
and be sure to copy the jaxp-1.2.2\lib\endorsed folder into your 1.4.x java
installation under %java_home%\jre\lib\endorsed

B) Fix your path
NOTE: Reseting the path is necessary for both ANT and straight-up XJC.bat
calls from DOS.

1) Export your path to a file
c:\> PATH > path.txt

2) edit path.txt removing any spurious java library pointers

3) in the batch file which sets up your examples, add a line early on which
sets the path to this new text.


So my setupsample.bat file looks like this:

REM -----------------------

REM Echo ON so I can see what is happening
@echo on
set PATH=C:\Program
Files\tcl\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program
Files\Editeur V4.06;G:\Program Files\jwsdp-1.1\jwsdp-shared\bin

REM Substitute i for any directory names with spaces so less quotes are needed
subst i: "G:\Program Files"

REM All the usual sets for jwsdp
REM Note: the documentation has some typos, so tread carefully, I think
REM this list of sets is correct.

set JAVA_HOME=I:\j2sdk1.4.1_02\bin
set JWSDP_HOME=I:\jwsdp-1.1
set JAXB_HOME=%JWSDP_HOME%\jaxb-1.0
set JAXB_LIBS=%JAXB_HOME%\lib
set JAXP_LIBS=%JWSDP_HOME%\jaxp-1.2.2\libs
set JWSDP_LIBS=%JWSDP_HOME%\jwsdp-shared\lib

REM now add the jaxb stuff to your class path
set PATH=%JAXB_HOME%\bin;%JWSDP_HOME%\jwsdp-shared\bin;%path%

REM now set the class path
set
CLASSPATH=%JAXB_LIBS%\jaxb-api.jar;%JAXB_LIBS%\jaxb-ri.jar;%JAXB_LIBS%\jaxb-xjc.jar;%JAXB_LIBS%\jaxb-libs.jar;%JAXP_LIBS%\jaxp-api.jar;%JAXP_LIBS%\endorsed\xercesImpl.jar;%JAXP_LIBS%\endorsed\xalan.jar;%JAXP_LIBS%\endorsed\sax.jar;%JAXP_LIBS%\endorsed\dom.jar;%JWSDP_LIBS%\jax-qname.jar;%JWSDP_LIBS%\namespace.jar;

REM -------------------

Now in my xjc.bat I also changed the following
1) Changed @echo off -> @echo on (again so I could see what was happening)
AND
2) I changed the call to xjc to eliminate some quotes which were causing
problems.

rem Execute the Launcher using the "xjc" target
"%JAVA_HOME%\bin\java.exe" -classpath
%PRG%;%PRG%\..;%PRG%\..\..\..\jwsdp-shared\bin;"%PATH%" LauncherBootstrap
-verbose xjc -DJAXB_HOME=%JAXB_HOME% -DJAVA_HOME="%JAVA_HOME%" %xOpts%

I hope this helps.

Thanks again,
Laura Ferguson