Using sdkman java in pycharm

I need to run java as an external process from the python script I'm running in pycharm.

I installed java 11 using sdkman.  I can invoke it from a shell, so I know it's installed.   I can't invoke it from the shell in pycharm or when running the code.

I've found pages that say to go to the project settings → project structure → settings, selecting “Add SDK from disk”, there is no such option.

I tried setting java_home to the sdkman path in my .zshrc file, but that didn't help.

How can I get this to work (or is it possible)?

I'm running on a M1 Max macbook.

Thanks,  Beth

0
2 comments

Elizabeth Kirby , would it help to set JAVA_HOME environment variable directly in the code?

import os
os.environ['JAVA_HOME'] = "/usr/local/java" # or any other path
0

I set JAVA_HOME in the env settings field in the run config & that fixed it.

It would be nice if there were a more general fix, but at least my code runs.  :-)

Thanks, Beth

0

Please sign in to leave a comment.