users@glassfish.java.net

Re: Standalone client of GlassFish v3

From: <glassfish_at_javadesktop.org>
Date: Wed, 10 Mar 2010 07:39:16 PST

Folks, the situation with the JARs is not all that complicated.

To run a client, whether it's a Java EE app client or a Java SE client that does its own look-ups, etc., you need to have the necessary GlassFish JARs physically present on the client system and logically accessible via the runtime classpath.

[b]Getting the JARs Present[/b]

If you are running on a system with GlassFish installed then that's already done. If not, then read about the package-appclient script. Its function is to gather up the files required for launching Java EE app clients, but that includes the same JARs you need to launch a Java SE client. In either case you are in control of where the files get installed and so you are in control of where the gf-client.jar file will reside.


[b]Getting the Runtime Classpath Correct[/b]

Yes, the Class-Path setting in gf-client.jar's manifest is long and intricate - but you don't have to worry about it. The paths are relative because using relative paths will work on every installation of GlassFish, regardless of where each user chooses to install it, as long as you don't move the installed files to different places after you install them.

To resolve relative paths in a JAR's Class-Path, Java SE uses the directory where the JAR file being processed resides. So, for gf-client.jar's Class-Path, the base directory is the directory where you find the gf-client.jar file - which is the modules directory in your GlassFish installation. But again, as long as you just refer to the gf-client.jar where it was installed everything works.

Now, as for getting the runtime class path set correctly, there is nothing magic about this. Long-standing Java SE behavior is that if you launch a Java app using java -jar then any -classpath setting on the command line is ignored. (see, for example, the discussion of the -jar option at http://java.sun.com/javase/6/docs/technotes/tools/solaris/java.html)

So that's why

java -classpath ${glassfish-install-dir}/modules/gf-client.jar:${path-to-your-jar} your-main-class

(all on one line, of course) will work but

java -classpath ${glassfish-install-dir}/modules/gf-client.jar -jar ${path-to-your-jar}

will not.

Does that help?

- Tim
[Message sent by forum member 'tjquinn' (timothy.quinn_at_sun.com)]

http://forums.java.net/jive/thread.jspa?messageID=391044