Option #2 works great for me (actually, JBoss does it for me though). Instead of having your users double click a jar, why not create a batch file that sets the property and executes the jar? One less step for the user and maybe will solve their nervousness about running a jar too.
As for your comment on #3, they say it's advanced but doesn't seem that hard. If I had to guess at how to do it from a quick check of the Java API I'd say 1) extend URLClassLoader 2) override findClass(String) 3) have the override read classes with name that starts with javax.xml.bind from a jar at a configurable path, delegate to super for all other classes 4) set context class loader of main application thread to use your custom class loader and all other threads should inherit. I haven't actually done this, but I don't think it would be all that hard.
Craig
_____
From: bthayer [mailto:bthayer_at_tqs.com]
To: users_at_jaxb.dev.java.net
Sent: Wed, 23 Dec 2009 13:27:57 -0500
Subject: Re: [ANN] JAXB 2.2 is released - Seriously?
I Can't get 2.1 to work yet! I wish I could just add it to my program's jar
but using NetBeans it seems impossible. I finally gave up and created one
build (of my program) for Windows and one for Unix and told my users to
access the jar from a mapped network drive or Unix alias and hope it runs.
These instructions do not seem practical to me:
7.1.2. Using JAXB 2.1/2.2 with JavaSE 6
JavaSE 6 comes with JAXB 2.0 API in rt.jar, newer releases (since update 4)
of JavaSE 6 contain JAXB 2.1 API. Therefore, using JAXB 2.1/2.2 with JavaSE
6 requires one to override a portion of rt.jar with the new API. There are
several ways to do this:
1. Place the 2.1/2.2 jaxb-api.jar into $JRE_HOME/lib/endorsed. This
essentially makes your JRE to "JRE 6 + JAXB 2.x". This won't affect any
other applications that use this JRE, and it's easy. On the other hand, in
various scenarios you may not be able to alter the JRE.
Fine for my PC but what about my users?
2. Use the system property java.endorsed.dirs when you launch your
application, and have it point to the directory that contains the 2.1/2.2
jaxb-api.jar. This allows you use use JAXB 2.1/2.2 without modifying the
JRE. Make sure not to include any other JAXB RI jar files (such as
jsr173-api.jar or jaxb-impl.jar.)
First you have to tell your users to use some advanced level argument on the
command line then make sure they type in the correct path. - not good for a
double-click crowd. My users are nervous double-clicking a jar file.
3. Implement a custom ClassLoader and block delegation to javax.xml.bind
package, so that code running inside this class loader will load the JAXB
API from elsewhere. This is a very advanced approach.
Love to see a tutorial on this using NetBeans please.
No matter which approach you take, make sure not to include jar files other
than jaxb-api.jar. Doing so, for example including jaxb-xjc.jar, may result
in classloading related errors such as "taskdef A class needed by class
com.sun.tools.xjc.XJCTask cannot be found: org/apache/tools/ant/...."
IMO - There's got to be a 4th approach. JAXB is difficult enough with
having to worry about deployment! Without some simpler way to get JAXB to
work I don't see new programmers adopting JAXB technology. I am always
looking for an alternative myself.
%-|
Martin Grebac wrote:
>
>
> If you want to work with the new JAXB api version on JDK 6 which itself
> contains older JAXB
> implementation, make sure you follow the endorsed dir setup as described
> in [4].
>
> [4]
> https://jaxb.dev.java.net/guide/Migrating_JAXB_2_0_applications_to_JavaSE_6.html#Using_JAXB_2_1_or_JAXB_2_2_with_JavaSE_6
> --
> Martin Grebac
> Sun Microsystems martin.grebac_at_sun.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
>
--
View this message in context:
http://old.nabble.com/-ANN--JAXB-2.2-is-released-tp26744560p26905661.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net