This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Use the build method
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Apr 06, 2006
03:51 AM
Load Classes from external jar
Hi,
I want to load some classes from an external jar file. The code goes as
URL[] url = new URL[]{new URL("jar:file:d:\\Install\\hello.jar!/")};
URLClassLoader loader1 = new URLClassLoader(url);
Class cls1 = Class.forName("Hello",true,loader1);
Method meth[] = cls1.getMethods();
for(int i=0;i {
if(meth.getName().equals("add"))
{
meth.invoke(cls1.newInstance(),new Object[]{});
}
}
But this throws an ClassNotFoundException. The output is
java.lang.ClassNotFoundException: Hello
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at com.installshield.test.event.dialog.swing.PanelDestination.enteredDes
tination(PanelDestination.java:263)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.installshield.event.ActionSequenceEngine$ActionTask.invokeJavaMet
hod(Unknown Source)
at com.installshield.event.ActionSequenceEngine$ActionTask.executeAction
(Unknown Source)
at com.installshield.event.ActionSequenceEngine$ActionTask.run(Unknown S
ource)
at com.installshield.event.ThreadPool.run(Unknown Source)
at java.lang.Thread.run(Thread.java:534)
Could anyone help me on resolving this.
Thanks in advance
Sudan
I want to load some classes from an external jar file. The code goes as
URL[] url = new URL[]{new URL("jar:file:d:\\Install\\hello.jar!/")};
URLClassLoader loader1 = new URLClassLoader(url);
Class cls1 = Class.forName("Hello",true,loader1);
Method meth[] = cls1.getMethods();
for(int i=0;i
if(meth.getName().equals("add"))
{
meth.invoke(cls1.newInstance(),new Object[]{});
}
}
But this throws an ClassNotFoundException. The output is
java.lang.ClassNotFoundException: Hello
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at com.installshield.test.event.dialog.swing.PanelDestination.enteredDes
tination(PanelDestination.java:263)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.installshield.event.ActionSequenceEngine$ActionTask.invokeJavaMet
hod(Unknown Source)
at com.installshield.event.ActionSequenceEngine$ActionTask.executeAction
(Unknown Source)
at com.installshield.event.ActionSequenceEngine$ActionTask.run(Unknown S
ource)
at com.installshield.event.ThreadPool.run(Unknown Source)
at java.lang.Thread.run(Thread.java:534)
Could anyone help me on resolving this.
Thanks in advance
Sudan
(1) Reply
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Apr 08, 2006
04:03 PM
Hi,
If you use a custom bean, you need to add in the build method a call for the putArchive, and give the jar as parameter (Assuming you need the jar that exist on your build environment).
Eyal
If you use a custom bean, you need to add in the build method a call for the putArchive, and give the jar as parameter (Assuming you need the jar that exist on your build environment).
Eyal
![](/skins/images/CC38E504FC9E1309DC48ACFEB4925670/responsive_peak/images/icon_anonymous_message.png)