简体   繁体   中英

jython java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: org/json/simple/ JSONObject

I needed to use a java code in python to reduce, so I chose Jython. after a while, I've managed to figure out how to run my code, but I'm having the strangest thing. When I write

from vohmm.corpus import Token;

most of the time, I'll get a

java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: org/json/simple/JSONObject

but, when I'll do it again(sometimes after 3 attempts) it will import the class, missing out some methods, but I'm able to use the class.

any one can figure this out?

thanks, Eyal

Jython uses a caching mechanism when starting up, basically going through all jars in your classpath and building wrappers. It's possible that in some cases that particular class is found and wrapped, and in others it isn't; maybe you have a lot of jars and you're hitting some recursion bug or limit.

In any case, I'd make sure that the jar including that specific class is at the beginning of your classpath, explicitly declared (ie using -cp C:\\path\\to\\my.jar;%CLASSPATH% ), so that jython will pick it up quickly every time.

This, of course, assuming you launch jython in the same way every time. If that's not the case, check that the launching parameters that you are using, including the starting directory, are the same in all cases.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM