Josh Winkler
Josh Winkler

Reputation: 165

Load a jar BEFORE a system jar

Is there any way to load a jar file BEFORE a system jar? I have a class that is newer than the one in the java system (1.5) that I am forced to use, but it breaks because java loads it's own first (from rt.jar, to be specific). Is there some way I can force it to load my own jar BEFORE system/rt.jar?

Upvotes: 2

Views: 1207

Answers (2)

Perception
Perception

Reputation: 80623

What you want is the (JVM specific) startup option -Xbootclasspath:/p. This will prepend the supplied list of paths and archives before the existing boot classpath, forcing any classes found to be loaded first.

java -Xbootclasspath/p:<pathtooverridejarhere> mypackage.MyClass

Note that:

  • It is against Oracles TOS to distribute modified JDK classes
  • Loading a newer version of a JDK class may still fail, due to dependency resolution issues.

Upvotes: 3

Michael-O
Michael-O

Reputation: 18415

You might try the ext or endorsed classpath.

Upvotes: 0

Related Questions