0

Alright, so. I have my own website with a applet loaded in a jar. I want to use a java program to load the jar through a URLClassLoader, and start the applet that way.

I'm using this code:

classLoader =  new URLClassLoader(new URL[]{new URL("http:/foo.com/applet.jar")});
                    applet = (Applet) classLoader.loadClass(code).newInstance();

It generates 403 errors, but when I check the error log on my website, it doesn't show that anyone 403'd.

Why is java outputting 403 errors, when my website log isn't?
If I open a urlconnection, and set the user agent, it works, but if I don't, it 403's.

So I was wondering, how can I set the user agent so the URLClassLoader doesn't error out. or is there another way to load the applet jar without having to download it on the user's PC?

Chris Shafer
  • 68
  • 1
  • 6

1 Answers1

0

Try using this constructor:

URLClassLoader(URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory)

By overriding some stuff in the factory, you should be able to set the user agent before it establishes a URL connection.

Byron Hawkins
  • 2,536
  • 2
  • 24
  • 34