This is the mail archive of the java-discuss@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: classpath question


Tom Tromey wrote:
> You can already set java.class.path at link time with -D.

True, but java.class.path is a system property.  If I override it I can't expect
the classloader to honor it, any more than I should expect
System.getProperties().put("user.dir", "/") to change my working directory.

> Maybe we
> should set the default in the compiler at link time?  Would that be
> sufficient?

I think so.  The command

$ gcj -Djava.class.path=/tmp CPTest.java --main=CPTest -o cptest

just happens to do that.  It also checks CLASSPATH at runtime and prepends it,
e.g.:

$ CLASSPATH=/usr/share/java ./cptest
classpath = /usr/share/java:/tmp
$ ./cptest
classpath = /tmp

Note libgcj.zip is absent, which seems wrong to me.

Ideally, I'd just like the gcj --classpath arg to persist in the compiled
executable, in other words:

$ gcj --classpath=/tmp ...

would effectively do:

$ gcj -Djava.class.path=/tmp --classpath=/tmp ...

Later we could add some option to compile selected resources into the program
image.  I'm undecided whether it still makes sense to check the environment
(i.e. CLASSPATH) in that case.

--
Jeff Sturm
jeff.sturm@commerceone.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]