Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Adding UNC paths to CLASSPATH

0 views
Skip to first unread message

Simon Andrews

unread,
Jan 20, 2004, 12:00:40 PM1/20/04
to
I've got a java (.jar) program which I'm trying to make available to the
whole of our organisation. To do this for other applications I've got a
network share I can stick the program in, which is visible to all and
then users just create a shortcut which points to that location. This
way there is only one copy of the program and a single point where I can
update it.

The problem I've got is that I can't properly set the CLASSPATH required
to get the program to run, as I need to reference the directory using a
UNC path (\\server\java_program), and this seems not to be recognised by
javaw. If I map the share to a drive letter and then use
x:\java_program it works fine, but I can't do that sitewide as I can't
guarantee that a particular drive letter will always be available.

Am I completely stuffed with trying to put a UNC location in a classpath
statement, or is there another way around this?

If it makes any difference we're using:

M:\>java -version
java version "1.3.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_02-b02)
Java HotSpot(TM) Client VM (build 1.3.1_02-b02, mixed mode)

Any help is much appreciated.

Simon.

Andrew Thompson

unread,
Jan 20, 2004, 12:28:10 PM1/20/04
to
"Simon Andrews" <simon....@bbsrc.ac.uk> wrote in message
news:bujmqf$k8t$1...@south.jnrs.ja.net...

| I've got a java (.jar) program which I'm trying to make
available to the
| whole of our organisation.

Do you have a manifest file that specifies
the main class?

| The problem I've got is that I can't properly set the CLASSPATH
required
| to get the program to run, as I need to reference the directory
using a
| UNC path (\\server\java_program), and this seems not to be
recognised by
| javaw.

..If you do, the users can open the
.jar from a link in a web page.

HTH

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site


Steve W. Jackson

unread,
Jan 20, 2004, 1:54:32 PM1/20/04
to
In article <bujmqf$k8t$1...@south.jnrs.ja.net>,
Simon Andrews <simon....@bbsrc.ac.uk> wrote:

>:I've got a java (.jar) program which I'm trying to make available to the

>:

You don't say what it is you need to refer to that directory for, but
perhaps you don't *really* need to refer to it in a classpath parameter.
Besides that, the default double-click behavior of javaw doesn't include
a classpath, expecting that the jar file will already contain a manifest
entry specifying the main class.

If this is all that's needed, then make sure your manifest contains one,
and make sure it refers to other jar files by name, without paths, which
will cause them to be assumed to be in the same directory with the main
jar file. Or specify them in a subdirectory and specify that in the
manifest, for example.

Another possibility, if you actually need runtime access to the
directory, is to simply have the code itself resolve the "user.dir"
system property. I'm pretty certain that it'll resolve correctly if a
user is actually able to see and double-click your main jar.

= Steve =
--
Steve W. Jackson
Montgomery, Alabama

Andrew Thompson

unread,
Jan 20, 2004, 2:29:48 PM1/20/04
to
"Steve W. Jackson" <stevew...@charter.net> wrote in message
news:stevewjackson-38A...@news.fu-berlin.de...

| In article <bujmqf$k8t$1...@south.jnrs.ja.net>,
| Simon Andrews <simon....@bbsrc.ac.uk> wrote:
|
| >:I've got a java (.jar) program which I'm trying to make
available to the
| >:whole of our organisation. To do this for other applications
I've got a
| >:network share I can stick the program in, which is visible to
all and
| >:then users just create a shortcut which points to that
location.

****

....This


| >:way there is only one copy of the program and a single point
where I can
| >:update it.
| >:
| >:The problem I've got is that I can't properly set the
CLASSPATH required
| >:to get the program to run, as I need to reference the
directory using a
| >:UNC path (\\server\java_program), and this seems not to be
recognised by
| >:javaw.

.....


| Another possibility, if you actually need runtime access to the
| directory, is to simply have the code itself resolve the
"user.dir"
| system property. I'm pretty certain that it'll resolve
correctly if a
| user is actually able to see and double-click your main jar.

You may be right, but the fact that the
OP's users are using a shortcut will
probably stuff that up. (I think it would
return the directory in which they store
the shortcut.)

The only reliable way I have found to get
'where am I' information is to use
Class.getResource()...

Steve W. Jackson

unread,
Jan 20, 2004, 3:12:17 PM1/20/04
to
In article <MkfPb.20648$Wa.1...@news-server.bigpond.net.au>,
"Andrew Thompson" <andr...@bigNOSPAMpond.com> wrote:

>:"Steve W. Jackson" <stevew...@charter.net> wrote in message

>:
>:

In my development environment, I use a shortcut to a batch file. I've
found that it returns the directory of the batch file's actual location.
We also create our product's installer with InstallAnywhere, which
creates an executable in the install location and a shortcut on the
desktop, which correctly points user.dir to the actual exe file's
location. So there's a pretty good chance they'll get what they want
from "user.dir" if indeed it's of any use to his users.

0 new messages