How to quickly create a self signed SSL certificate using openSSL

To create a self-signed certificate on Ubuntu use this one-line command:

sudo openssl req -x509 -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/private.key -out /etc/ssl/certs/certificate.crt

You will be asked to choose a challenge password, and answer a few questions. The tool give you examples of the requested informations.

It will work on most Linux/Unix distributions. If you use an other distribution you may want to adapt the path.

Here is a description of the above command :

openssl
The program/tool that manages certificates and keys.

req -x509
Tells the utility that we want to use X.509 standard to make the self-signed certificate.

-days
Number of days the certificate will be considered as valid

-newkey rsa:2048
Tells the utility to simultanously generate a new RSA certificate and key that is 2048 bits long.

-keyout /etc/ssl/private/private.key
Tells openSSL where to place the private key.

-out /etc/ssl/certs/certificate.crt
Tells OpenSSL where to place the public certificate.

Java Certification Path

Java Certifications are managed and delivered by Oracle who offers a lot of certifications in many IT fields.

The following is an optimal path of certification for a Java Developer. The image does not cover all java certifications and this path is not the only possible one for a Java Developer.

Java Certification Path

Optimal Java Certification Path

 

To get one of these certifications you need complete an exam. To register for an exam you have to register with the Oracle Education System and buy a voucher.

How to display an animated gif in java swing

The type ImageIcon (sub-type of Icon) allows to display an animated GIF. Example :

// We suppose you have already set your JFrame 
Icon imgIcon = new ImageIcon(this.getClass().getResource("ajax-loader.gif"));
JLabel label = new JLabel(imgIcon);
label.setBounds(668, 43, 46, 14); // You can use your own values
frame.getContentPane().add(label);

You know an other way ? leave a comment !

Java native keyword

When applied to a method declaration, the Java « native » keyword indicates to the jvm that the method is implemented in the platform code .
A method marked as native cannot have a body.

Oracle’s definition of the native keyword :

A Java keyword that is used in method declarations to specify that the method is not implemented in the same Java source file, but rather in another language.

 

How to display all system properties in Java

This code displays all system (jvm) properties in java :

import java.util.Iterator;
import java.util.Properties;

public class Test {

 public static void main(String[] args) {
   Properties properties = System.getProperties();
   Iterator<Object> iter = properties.keySet().iterator();
   while(iter.hasNext()){
    String key = (String) iter.next();
    System.out.println(key + " = " + properties.getProperty(key));
   }
  }
 }

 

Here is a set of default system properties you can access:

java.runtime.name
sun.boot.library.path
java.vm.version
user.country.format
java.vm.vendor
java.vendor.url
path.separator
java.vm.name
file.encoding.pkg
user.country
user.script
sun.java.launcher
sun.os.patch.level
java.vm.specification.name
user.dir
java.runtime.version
java.awt.graphicsenv
java.endorsed.dirs
os.arch
java.io.tmpdir
line.separator
java.vm.specification.vendor
user.variant
os.name
sun.jnu.encoding
java.library.path
java.specification.name
java.class.version
sun.management.compiler
os.version
user.home
user.timezone
java.awt.printerjob
file.encoding
java.specification.version
java.class.path
user.name
java.vm.specification.version
sun.java.command
java.home
sun.arch.data.model
user.language
java.specification.vendor
user.language.format
awt.toolkit
java.vm.info
java.version
java.ext.dirs
sun.boot.class.path
java.vendor
file.separator
java.vendor.url.bug
sun.io.unicode.encoding
sun.cpu.endian
sun.desktop
sun.cpu.isalist

How to get current TimeStamp in Java

There are several ways to get the current timestamp in Java. This example works in Java6, 7 and 8.

Please note that Java 8 contains now a simpler and more efficient date and time API.

// Using the java.sql.Timestamp class
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
System.out.println(timestamp);

// Using the Date object
Date date = new Date();
System.out.println(new Timestamp(date.getTime()));

 

What is new in Java 8

Java 8 is a major release of the java programming language. It introduces new features and enhancements. The most significant ones are the following.

Lambda expressions

New Date and Time API

Method references

Default methods

Repeating annotations

Type annotations

Stream API

Optional

Narshon

new tools and utilities