SilentSys / orhelper

orhelper is a module which aims to facilitate interacting and scripting with OpenRocket from Python
GNU General Public License v2.0
16 stars 17 forks source link

Installation problems: Java package 'net' is not valid #5

Closed christophfroehlich closed 2 years ago

christophfroehlich commented 2 years ago

Hi! I just made a clean install on a Windows 10 machine and struggle to run even the example scripts.

  File "PATH\TO\FILE\_orhelper.py", line 53, in __enter__
    self.openrocket = jpype.JPackage("net").sf.openrocket
AttributeError: Java package 'net' is not valid

I installed orhelper via pip on miniconda3-py39, Windows 10. I had a problem on building jpype with python 3.10 and had to build jpype manually with this source, see the following github-PR

I tried openjdk 1.8.0_312-1 but also oracle jdk 1.8.0_202-b08 via setting JAVA_HOME.

From anaconda3 prompt:

java -version
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)

echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_202

python
Python 3.10.0 | packaged by conda-forge | (default, Nov 10 2021, 13:20:59) [MSC v.1916 64 bit (AMD64)] on win32

The jar-file is located in the examples directory, andjava -jar OpenRocket-15.03.jar loads OR successfully.

Could you give me any hint on how to fix this? Did I miss something during installation, or is there any incompatibility with the newest releases I just installed?

SilentSys commented 2 years ago

Just to gain a better understanding of your situation, is the CLASSPATH environment variable set to anything, or is it unset (that's okay too)?

I currently have it working on Windows 10 with Oracle JDK 1.8.0_202-b08 like you. Only difference is I'm not using Conda and I'm using Python 3.7.

Could you please try again with Python 3.7 in Conda so that we can narrow down if the issue is the Python version or Conda?

SilentSys commented 2 years ago

After doing a bit more research, it looks like jpype doesn't yet support Python >3.8 very well. You could try python 3.9, but 3.8 looks like the latest fully supported version.

christophfroehlich commented 2 years ago

I already tried that and downgraded python yesterday, but it seems that I forgot to reinstall all dependencies properly. Today (probably after restarting conda), I got new error messages and started reinstalling everything with pip -> same result.

python
Python 3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32

Then I tried to delete CLASSPATH and voila, it worked! I think I've found the mistake: CLASSPATHwas pointing to the folder where the jar file is, not to the file itself! Even if I have the jar file in the same folder and set CLASSPATHto any other folder it fails. Honestly, I have no glue of java and its system variables, nor do I know now if it would have worked with python3.10, but I'm happy that you pointed me to the CLASSPATHissue. Thanks!