0

I am trying to test an apk file using Eclipse, Java, Selenium, Cucumber, and Appium.

In Windows Environment Variables, under System Variables, I have the value of JAVA_HOME set to "C:\Program Files\Java\jdk-15.0.2".

In Eclipse, I'm using the latest JDK 15.0.2 in my run configuration. When I execute a cucumber test, I get the following error:

C:\Users\x\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v4.17.4.apk'. Original error: java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0

I'm using the latest version of JDK so why am I getting this error and how can I resolve it?

Neil Hawke
  • 33
  • 4

1 Answers1

1

List of Java class file format major version numbers? shows which jdk versions use which class file versions. If you are indeed using java 15, then your jdk should recognize class files up to 59. But your error message indicates that it only recognized versions up to 52, which suggests that you're actually using java 8.

Erik
  • 578
  • 2
  • 9
  • I went into the project's properties settings --> Java Compiler --> Compiler Compliance Level and changed that to 12 (highest level). Still getting the same error. – Neil Hawke Mar 07 '21 at 00:46
  • There's a difference between the compiler target level and the runtime environment. I don't have Eclipse installed here, so can say exactly which setting is the problem. – Erik Mar 07 '21 at 00:52
  • https://stackoverflow.com/questions/12588537/how-to-change-jdk-version-for-an-eclipse-project might be helpful – Erik Mar 07 '21 at 00:54
  • The runtime environment is 15.0.2. I checked that by clicking on Windows --> Preferences --> Java --> Installed JREs – Neil Hawke Mar 07 '21 at 01:00
  • It is possible to have multiple versions of Java installed at the same time. And the *evidence* shows (unequivocally!) that you *do* have a Java 8 JRE or JDK installation on your system, *and* that your application is being run using that. – Stephen C Mar 07 '21 at 03:15
  • For what it is worth, it is the $PATH variable that determines what you get when you type `java` ... not $JAVA_HOME. Than the version that Eclipse uses is determined by the "eclipse.ini" file; see https://stackoverflow.com/questions/18469170/ – Stephen C Mar 07 '21 at 03:21
  • @StephenC is $PATH a system variable or a user variable? – Neil Hawke Mar 07 '21 at 05:14
  • (In Windows parlance it is PATH rather than $PATH.) Either. As far as an application ... or the command shell ... is concerned, it makes no difference where the variable setting comes from. – Stephen C Mar 07 '21 at 05:27
  • @StephenC I uninstalled all the other JDKs I had except for 15.0.2 and changed my eclipse.ini file. I'm no longer getting the same error but a new one instead (something about an app's launcher not working). Anyways, I consider this question to be resolved. – Neil Hawke Mar 07 '21 at 06:11