开发者

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 (i.e. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜