Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

How to Install Java 8 on CentOS 7

Java is most common requirement for many of the Open Source softwares. You can follow below steps to install Java on CentOS vm.

You can first check the list of available packages for Java using below command.

$ yum search java | grep 'java-'


You will get the list like above. Now depending on what is your requirement you can choose the package. If you don't see any list as above, you will need to update the REPO for java.

To install JRE you can run below command.


$ sudo yum install java-1.8.0-openjdk.x86_64

To install JDK you can use below command.

$ sudo yum install java-1.8.0-openjdk*

The above commands will ask for downloading the required dependencies, press Y and enter to continue with installation. Once installation completes it will display the dependencies installed and complete message.

Now you can verify the installation by running below command.

$ java -version
openjdk version "1.8.0_144"
OpenJDK Runtime Environment (build 1.8.0_144-b01)
OpenJDK 64-Bit Server VM (build 25.144-b01, mixed mode) 

You should see the java version as shown in above output.

Error : java.lang.SecurityException: Can not initialize cryptographic mechanism

During certificate import using InstallCert.Java, I faced this issue. This can cause if you don't have required restriction policy file or the key size is greater than the once deployed by Java by default which is 128 bit. 

This can be solved by downloading the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files from Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files  and copying them in your JRE.

Error : unable to find valid certification path to requested target

I was trying to run Java application, which was using REST Template to implement rest client. The application was connecting to REST service (REST API's) over SSL. The certificate used for SSL was self signed certificate.

The self signed certificate was causing error "unable to find valid certification path to requested target" every time I tried to connect to REST Service. 

In order to resolve this error, I had to add the certificate to the JVM key store. I tried multiple steps, even corrupted the keystore but finally was able to run application successfully. 

You would need InstallCert.Java to successfully import the certificate which can be found at InstallCert.Java

Above git repo has ReadMe which details out all steps required for importing the certificate. 
If you happen to corrupt the keystore you can follow below link to restore it.

http://architecturalatrocities.com/post/19073788679/fixing-the-trustanchors-problem-when-running


Caching is a technique used to store frequently accessed data in a temporary storage layer to improve system performance and reduce latency....