Is there a way to get a Executable Jar to use the system classpath.
I have an app the uses the SqlServer jdbc driver, and if I specify the classpath in the manifest it works, but if I leave the classpath out of the manifest it can;t find the jdbc driver and the classpath for the jdbc driver is in the system classpath.
I really don't want to specify the classpath because it is very likely that the JDBC driver is already installed on the clients workstations.
All the workstations are XP sp2
Again, I have search the internet but have not turned anything up on this. [ March 20, 2006: Message edited by: Steve Gibson ]
An insane man is perfectly sane in his own mind - cira 1984 a very young chemically altered S.Gibson<br /> <br />Yes we do build our software idiot proof, problem is they keep building better idiots. - (used by S.Gibson to break the tension during a confernece call with the CIO)
Originally posted by Dave Wingate: Have you tried somethng along the lines of:
java -cp "%CLASSPATH%" -jar myjarfile.jar
I think that should probably work.
Nope.... does not work. Matter of fact specifing the complete classpath does not work either. I believe that I read on the web somewhere that a jar file ignores externally specified classpaths... but I have a hard time believing that (but it could be true). [ March 20, 2006: Message edited by: Steve Gibson ]
Using the -jar switch will ignore the -classpath switch (and CLASSPATH environment variable). There are various available options - off the top of my head, and probably incomplete: 1. Use the Class-Path manifest entry 2. Repackage all your jars into one single jar 3. Don't use the -jar switch (instead specify a main class) 4. Write your own class loader to load from the various jars that would otherwise be in the classpath.
[Steve]: I believe that I read on the web somewhere that a jar file ignores externally specified classpaths... but I have a hard time believing that (but it could be true).
Well the place to look for such info would be in the documentation, specifically under JDK Development Tools, the java program specifically, under standard options. Under the -jar option it says: "When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored." The oroginal idea of JAR files seems to have been that they'd be completely self-contained. That's not always practical, however, in which case use one of the alternatives Tony listed.