Issue with Java version in linux.sh execution?

I have a .sh file as shown below.

export JAVA_HOME=/usr/jdk/latest
export PATH=$JAVA_HOME/bin:$PATH
java -Dlogback.configurationFile=./conf/logback.xml  -cp CLASSPATH:Client.jar com.test.main.Client 
exit

      

If i run the script i get below error message.

Exception in thread "main" java.lang.UnsupportedClassVersionError: com/test/main/Client : Unsupported major.minor version 52.0

      

I read some doc and their story because of a problem with the java version this is happening. I am checking my local machine version and Linux server version. Both are the same. I am using gradle 2.4 to build my application and set sourceCompatibility and targetCompatibility to 1.8.

sourceCompatibility = 1.8
targetCompatibility = 1.8

      

Local Java version.

java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b15)
Java HotSpot(TM) Client VM (build 25.45-b02, mixed mode)

      

Linux server Java version

java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

      

If I just edit the .sh file (add a space) and run it works fine.

Could you please help someone to solve this problem?

+3


source to share


1 answer


You are using an old version of java (up to 8) when compiling for 8.



Download jdk8, install it and point your JAVA_HOME

(in script) to the newly installed jdk.

0


source







All Articles