The environment I'm having a few issues with at the moment is a CentOS6 environment with Java. Previously Java7 was installed, and a recent update to a Java web application was pushed with new features specifically using the Java8 LocalDate.now() function. Naturally Java8 was installed so that it would work - but - it didn't.
I've tried following the OpenJDK 8 installation instructions here (and updating the 'alternatives' too) and this didn't work - https://www.digitalocean.com/community/tutorials/how-to-install-java-on-centos-and-fedora#install-openjdk-8
I've also tried following the installation of Oracle Java 8 version on the same link, which didn't work due to the new annoying licencing issues with Oracle and the commands just kept saying I was unauthorised to download the .tar file.
I'm a bit lost on what to try next. From what I can see, I 'think' the version of Open JDK 8 is the build a few versions before LocalDate.now() was introduced based on;
java -version
command saying;
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)
Which looks to be build 25. Yet according to this link, https://coderanch.com/t/716444/java-lang-ClassNotFoundException-Didn-find, it looks like the minimum version of the build is Version 26 to use the LocalDate.now() function.
Ideally I'd like to use the Oracle JDK 8 version to match the development environment, but I can't get that to work either. Oracle is annoying. This is the error message I get when trying to run the commands on the Digital Ocean link around installing the Oracle JDK 8;
Connecting to login.oracle.com|209.17.4.8|:443... connected.
HTTP request sent, awaiting response... 401 Authorization Required
Authorization failed.
Not sure if there is another flag that I need to pass through on the command which includes login credentials, I've not found any guides on this yet.
Update1
Just installed Java8 via AdoptOpenJDK as suggested and configured to use via 'alternatives', the 'java -version' outputs the following;
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-b09)
Eclipse OpenJ9 VM (build openj9-0.17.0, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20191017_442 (JIT enabled, AOT enabled)
OpenJ9 - 77c1cf708
OMR - 20db4fbc
JCL - 97b5ec8f383 based on jdk8u232-b09)
Yet I'm still seeing the error output in the log files;
java.lang.ClassNotFoundException: java.time.LocalDate
Update 2
Following the recommendation to get back to the real basics, this has helped, but caused more confusion. I've tested;
1) Compiling locally a HelloWorld with a Main method, pushing the .class file to the server and running the file with the java command - which works
2) Creating locally a HelloWorld.java with a Main method, pushing the .java file to the server, compiling on the server with javac to create the HelloWorld.class, and running the file with the java command - which works
3) Creating locally a HelloWorldServlet.java, compiling locally, pushing the .class file to the server, and running /HelloWorld in the browser - which fails and throws the error.
As such, I'm starting to wonder if it's something to do with how Tomcat 7 is setup. It's actually managed by Easy Apache 3 via cPanel's WHM which doesn't help the matter as it's all quite old and really needs a significant upgrade.
It's frustrating because this 'just works' on a standard Linux box with Apache Tomcat installed. I'd ideally like to get this working as-is so I can procrastinate further and avoid having to do a full server re-build, migration and web application setup - but - it's not looking good...
Any final thoughts on options to try?