Tag Archives: Java

Signing Java Applets Using RSA Certificate

Generate a private/public key pair with the RSA algorithm. $ keytool -genkey -keyalg rsa -alias keyname Enter keystore password: password What is your first and last name? [Unknown]: What is the name of your organizational unit? [Unknown]: What is the … Continue reading

Posted in Java | Tagged | 1 Comment

Setting Up Log4j Quickstart Guide

Log4j is an open source tool developed for putting log statements into your Java application. It’s allows log statements to remain in shipped code while giving the user the ability to enable logging at runtime without modifying any of the … Continue reading

Posted in Java | Tagged | Comments Off

Setting Default JVM in Ubuntu

There are circumstances where you may need to have more than one version of Java installed, but how do you switch between them? Execute the following command to list the installed JVMs: $ sudo update-alternatives –config java Simply enter the … Continue reading

Posted in Java, Ubuntu | Tagged , | Comments Off

Java Code Snippet for Sending Email using Gmail SMTP Server

The partial code below shows how to sent an email using the Gmail’s SMTP server: Properties properites = new Properties(); properties.put(“mail.smtp.host”, “smtp.gmail.com”); properties.put(“mail.smtp.port”, “25″); properties.put(“mail.smtp.auth”, “true”); properties.put(“mail.smtp.starttls.enable”, “true”); properties.put(“mail.smtp.socketFactory.port”, “465″); properties.put(“mail.smtp.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”); properties.put(“mail.smtp.socketFactory.fallback”, “false”); Session session = Session.getInstance(properties, new Authenticator() … Continue reading

Posted in Java | Tagged | Comments Off

Java Code Snippet for Parsing Strings into Date

SimpleDateFormat formatter = new SimpleDateFormat (“yyyy-MM-dd”); String input = “2007-05-04″; Date d; try { d = formatter.parse(input); } catch (ParseException e) { e.printStackTrace(); }

Posted in Java | Tagged | Comments Off