ok, I am now using this to load the class:
URLClassLoader child = new URLClassLoader(new URL[]
{ jarFile.toURI().toURL() }, this.getClass().getClassLoader());
URL url = child.findResource("META-INF/MANIFEST.MF");
Manifest manifest = new Manifest(url.openStream());
Class<? extends RaspberryPi> main = (Class<? extends RaspberryPi>) child.loadClass(manifest.getMainAttributes().getValue("Main-Class"));
RaspberryPi pi = main.newInstance();
ret = pi;
child.close();
However, that doesnt automatically load the other classes for me... and its not possible for me to just add them into that code to laod them because I dont know what they are going to be... so... How do i fix this? In the object pi/ret, I am using another class and since it isnt loaded, i get this:
2013-05-19 13:13:57 [INFO] [STDERR] Exception in thread "Thread-14" java.lang.NoClassDefFoundError: com/sci/ss/SciScriptEngine
2013-05-19 13:13:57 [INFO] [STDERR] at com.sci.RPI.run(RPI.java:144)
2013-05-19 13:13:57 [INFO] [STDERR] at java.lang.Thread.run(Thread.java:722)
2013-05-19 13:13:57 [INFO] [STDERR] Caused by: java.lang.ClassNotFoundException: com.sci.ss.SciScriptEngine
2013-05-19 13:13:57 [INFO] [STDERR] at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
2013-05-19 13:13:57 [INFO] [STDERR] at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
2013-05-19 13:13:57 [INFO] [STDERR] at java.security.AccessController.doPrivileged(Native Method)
2013-05-19 13:13:57 [INFO] [STDERR] at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
2013-05-19 13:13:57 [INFO] [STDERR] at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
2013-05-19 13:13:57 [INFO] [STDERR] at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
2013-05-19 13:13:57 [INFO] [STDERR] ... 2 more
And I don't know how to fix it. Ideas?