0

I have a shell script that runs some java program on a remote server. But this shell script is to be executed by a python script which is on my local machine.

Here's the flow : Python script executes the shell script (with paramiko), the shell script then executes a java class.

I am getting an error : 'The java class could not be loaded. java.lang.UnsupportedClassVersionError: (Unsupported major.minor version 50.0)' whenever I run python code.

Limitations: I cannot make any changes to the shell script.

I believe this is java version issue. But I don't know how to explicitly have a python program to run in a specific java environment.

Please suggest how I can get rid of this error.

The java version of unix machine (where shell script executes) : 1.6.0 Java version of my local machine (where python script executes): 1.7.0

  • The error suggests that your python executable has Java **5** or lower on the path, as 50.0 is the class version of Java 6. – Mark Rotteveel May 21 '19 at 07:17

1 Answers1

1

The shell script can stay the same, update java on the remote system to java 1.7 or later. Then it should work.

Another possibility could be to compile the java application for java 1.6 instead. The java compiler (javac) has the arguments -source and -target and adding -source 1.6 -target 1.6 when compiling the application should solve this issue, too (but limits the application to use java 1.6 features).

Also be aware: If you use a build system like gradle or maven, then you have a different way to set source and target version.

Konrad Neitzel
  • 736
  • 3
  • 7