This site requires JavaScript, please enable it in your browser!
Greenfoot back
fejfo
fejfo wrote ...

2016/8/24

Exporting a project with libraries

fejfo fejfo

2016/8/24

#
I'm trying to use a custom shapes library it works fine in the editor but when I export to a jar file I get a no class def found error
java.lang.NoClassDefFoundError: sl/shapes/StarPolygon
	at ExplodingBullet.<init>(ExplodingBullet.java:33)
	at ExplodingBullet.<init>(ExplodingBullet.java:50)
	at Shooter.shootExploding(Shooter.java:70)
	at Boss1.act(Boss1.java:394)
	at greenfoot.core.Simulation.actActor(Simulation.java:594)
	at greenfoot.core.Simulation.runOneLoop(Simulation.java:552)
	at greenfoot.core.Simulation.runContent(Simulation.java:215)
	at greenfoot.core.Simulation.run(Simulation.java:205)
Caused by: java.lang.ClassNotFoundException: sl.shapes.StarPolygon
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	... 8 more
I have the library in Program Files (x86)\Greenfoot\lib\userlib and in project/libs (I made the libs folder) I other discusions said to add this : static { final NativeLoader loader = new NativeLoader(); loader.addClasspath( "./+libs/jshapes.jar" ); loader.loadClass( "sl.shapes.StarPolygon"); } to the world class (I assume outside of any method) but greenfoot can't find NativeLoader and I couldn't find where to import it from. So where do I import it from and is my code/library location correct?
fejfo fejfo

2016/8/25

#
I solved it with a by decompiling the library a dirty solution. So I still want to know the proper solution
You need to login to post a reply.