Java Import Error when running hello_world.py
Installation ran without issues. However, when I try to run any python script, I get the following error:
I am pretty sure that I installed all dependencies properly.
Thanks for the help
I'm a bit surprised you don't have a huge list of output lines after it says building .../microrts.jar..., listing all the class files it's compiling and including. I always get that, though I never build on Windows, only on Linux (or, actually: Windows Subsystem for Linux). Not sure if that matters.
What does the microrts.jar file you get at the filepath it mentions look like? Is there one at all? How big is it? Can you open it as an archive and take a screenshot of what's in there?
Thanks for the reply!
There is no microrts.jar file at that location or anywhere else, so I think it just fails building. Could it be that the filepaths are just wrong because of "/" instead of "\"?
I'll try WSL and see if it works.
Maybe, not sure. Or maybe just something else about the build script is Linux-specific. Personally I do indeed use WSL though, and would recommend that anyway. Don't know if it should matter for the build script (maybe it does), but regardless of that, I would also recommend it because in my experience, frameworks like PyTorch are also often a pain in Windows.
I am also running into this issue specifically after trying to get this to run on my laptop as well after successfully getting it to run on my PC. I am on Windows
`$ python hello_world.py removing C:\Users\40179558\MicroRTS-py\gym_microrts\microrts/microrts.jar... building C:\Users\40179558\MicroRTS-py\gym_microrts\microrts/microrts.jar... C:\Users\40179558\MicroRTS-py Traceback (most recent call last): File "org.jpype.JPypeContext.java", line -1, in org.jpype.JPypeContext.callMethod Exception: Java Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "C:\Users\40179558\AppData\Local\pypoetry\Cache\virtualenvs\gym-microrts-Llpb_R3--py3.9\lib\site-packages\jpype\imports.py", line 195, in find_spec cls = _jpype._java_lang_Class.forName(name, True, _jpype.JPypeClassLoader) java.lang.java.lang.ClassNotFoundException: java.lang.ClassNotFoundException: rts.units.UnitTypeTable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\40179558\MicroRTS-py\hello_world.py", line 10, in
Building using WSL works for me, so I assume the problem is because of Path format and/or Windows can't run .sh out of the box (Git for Windows adds integrations that allows it. These integrations might not encompass cmd.exe by default)
You may still get the ImportError: Failed to import 'rts.units.UnitTypeTable error after running build.sh in WSL, though. If it's the same issue I was having, your Java version doesn't match. If this is the case, change line 8 in build.sh to:
javac -d "./build" -cp "./lib/*" --release 8 -sourcepath "./src" $(find ./src/* | grep .java) and rerun build.sh. You should probably also set autobuild=False in the env, but that might not be necessary if you can't build with Windows.
I noticed that some of the build instructions on the MicroRTS page don't seem to be complete for Windows. I had to do a few steps in WSL because of that.