atomictom
atomictom

Reputation: 143

Importing Java classes into Jython using .class files instead of jars

I've been searching for a while and cannot seem to find an answer to this problem. Is it possible to import a user-defined .class file into Jython directly without it being a .jar. I want to use Jython to test files I'm writing in java (I'm using Netbeans if this changes anything). I intend to eventually use Jython as both a scripting language (it's going to be a game) and for the main loop code. But for now, I cannot even get Jython to import my .class files, and I really do not want to have to make everything a .jar each time I want to test the code or try something...

I have already added the folder containing all the .class files to both sys.path and classpath. When I try importing the package ('x86Wars'...'cause it's based on Advance Wars which was for the Gameboy Advance...) it gives me:

Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
ImportError: No module named x86Wars

But when I try importing the .class file name directly (I have actually added both the folder containing the .java source and the .class one), it gives me:

java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: FullScreenDisplay (wrong name: x86Wars/FullScreenDisplay)

Any help would be greatly appreciated!

Upvotes: 1

Views: 1667

Answers (1)

Daniel Teply
Daniel Teply

Reputation: 1974

Are sure the folders mimick the package name correctly? From the root youi have added to the python path (and classpath), you must have one folder for each dotted name for com.game.x86wars you should have /com/game/x86wars/class.class

Upvotes: 1

Related Questions