How to specify URLStreamHandlerFactory in jdk command line?

J

jacksuyu

I have a special URLStreamHandlerFactory and want to set to an
existing jdk application.

How to do it without change java code?

Thank you.
 
O

Oliver Wong

I have a special URLStreamHandlerFactory and want to set to an
existing jdk application.

How to do it without change java code?

Given that URLStreamHandlerFactory is an interface and thus contains no
behavioural code, this sounds like a really bad idea.

But if you really wanted to do this, I suppose you could go into your
JRE directory and mess around with the JAR/ZIP files to replace th existing
stuff there with your new class file.

- Oliver
 
T

Thomas Hawtin

I have a special URLStreamHandlerFactory and want to set to an
existing jdk application.

How to do it without change java code?

The two obvious choices are:

Use a Java Agent to call URL.setURLStreamHandlerFactory, but not
actually do any instrumentation. I've got an example of doing something
similar with EventQueue.push.

http://jroller.com/page/tackline?entry=detecting_invokeandwait_abuse

The alternative is to set -Djava.protocol.handler.pkgs=mypackage, then
instead of using URLStreamHandlerFactory provide URLStreamHandler
classes with no-arg constructors and names of the form
mypackage.protocol.Handler. See the source code to URL...

Tom Hawtin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top