Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to select jar files to import myself.

Status
Not open for further replies.

lovekang

Programmer
Feb 16, 2006
86
KR
the system have a system-specific jar file named secu.jar having the same package structure in jce.jar from sun.
I have to use javax.crypto.cipher in jce.jar not secu.jar.
other part of my source code has to use javax.crypto.cipher in secu.jar.
so I have not to change the classpath of jar files.

is there a way which the jar file I use from my source?
 
I'd rename cipher in my application jar.

Otherwise, you'd need to play with classloaders, not a trivial issue.

Cheers,
Dian
 
thanks.
I did it with classloader like the below.

public Class getCipherClass() {
Class c = null;
try {
URL urlA = new File("C:/Project/WEB-INF/lib/jce.jar").toURL();
URL[] urls = { urlA };
URLClassLoader ulc = new URLClassLoader(urls);
//
c = Class.forName("javax.crypto.Cipher", true, ulc);
} catch (Exception e) {
e.printStackTrace();
}
return c;
}
 
Nice you got it working, but be careful with that, it has a lot of issues.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top