Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 JAVA


  Add compiler argument to build Maven project

Maven is a software project to manage a project's build, reporting and documentation from a central piece of information. It's now widely used t build and deploy projects. It can help automatically maintain the dependencies of projects. There is a central project configuration file named pom.xml. Here you can configure the project you want to build. In this post, we will show you how to add compiler argument when using javac to compile Java source code. Sometimes we need to pass compiler arguments when we compile source code, for example, we may want to specify the -source and -targe...

25,596 1       MAVEN COMPILER ARGUMENT COMPILER OPTION JAVA 8


  Generating CSR using Java

A CSR(Certificate Signing Request) is a kind of request generated by an application and is to be sent to a Certificate Authority to create a signed certificate which can be distributed. It usually contains certificate information such as subject name, public key info and signature info.In Java, keytool can be used to generate a certificate request with option -certreq.  But sometimes if an application wants to create a CSR programmatically, keytool will not do a favor, instead you should use APIs provided by Java to generate CSRs.Basically the steps to generate a CSR are :Get the key...

25,208 0       JAVA SECURITY CSR CERTIFICATE REQUEST


  JShell -- The command line tool to run Java code in Java 9

Java 9 is currently a work-in-progress and is planned to be GAed in March 2017. Quite a few new features will be introduced in the new release. The coolest feature is project Jigsaw which is to modularize the Java packages so that a customized JDK can be built and shipped with only the necessary modules to fulfill their project requirement. Apart from this feature, another big new feature is project Kulla -- JShell.In simple, JShell is a command line tool which can be used to run Java code snippet without wrapping them into classes. It is similar to tools for other languages suc...

24,505 8       JAVA 9 JSHELL KULLA


  Different types of keystore in Java -- PKCS11

PKCS11 keystore is designed for hardware storage modules(HSM). It's an interface to talk to the HSMs. It doesn't actually store any keys but provide a set of classes to communicate with the underlying HSM. The actual keys and certificates are stored on the HSMs.The reason for storing the keys and materials is to ensure security and efficiency. Since the keys are on the HSMs, they are safe to be stolen. All encryption/decryption operations are performed on the HSMs as well, this increase the processing speed. They are frequently used in applications requiring high speed and extra sec...

24,138 2       JAVA KEYSTORE PKCS11 HSM


  Using Java keytool programmatically

Java provides a command line tool to access and operate different keystore which store keys and certificates. This tool is named keytool and is located at \bin. On command line, you can issue below command to generate a keystore named mytest.jks which contains a private key and certificate chain.keytool -genkeypair -alias mykey -keyalg RSA -sigalg SHA256withRSA -dname CN=Java -storetype JKS -keypass password -keystore mytest.jks -storepass passwordSometimes, in testing purpose, we may want to issue these command in our applications instead of start a command line terminal. This is...

23,877 14       JAVA KEYTOOL


  Difference between Enumeration and Iterator in java interview question and answer

This tutorial explains about what are the differences between Iterators and Enumeration and similarity of both interface which may be asked in a core java interview. Functionalities of both Iterator & Enumeration interfaces are similar that means both generates a series of all elements of the object which is to have its values iterated that can be traversed one at a time using next() method incase of Iterator and nextElement() method incase of Enumeration. The more powerful newer interface Iterator takes place of the old interface Enumeartion in the Java Collections Framew...

23,341 1       JAVA ITERATOR ENUMERATION


  Use Java ThreadLocal with caution

According to Oracle documentation, ThreadLocal is a class provides thread-local variables. These variables differ from their normal counterparts in that each thread that accesses one (via its get or set method) has its own, independently initialized copy of the variable. ThreadLocal instances are typically private static fields in classes that wish to associate state with a thread. In short, ThreadLocal variables are variables belong to a thread, not a class or an instance of a class.One common use of ThreadLocal is when you want to access some non thread-safe objects in threads without using ...

22,990 0       JAVA MEMORY LEAK THREADLOCAL


  Generate certificate from cert file in Java

A certificate is often used to prove the identity of a server. The certificate will contain information such as the subject and issuer of the certificate. It will also contain the validation date of the certificate. A certificate is often exported to an external cert file which is transferred over the internet. We will often see its use in SSL communication which provides secure communication between two entities.In this post, we will show how to read the data from an external certificate file and generate a X509 certificate object with the data. This object can then be used to conduct other o...

22,944 2       JAVA EXAMPLE X509 PKCS12 CERTIFICATEFACTORY