Category: Java

Running Play Framework as services in Production Ubuntu

Running Play Framework as services in Production Ubuntu

Here are steps to deploy Play Framework to Ubuntu as services : 1. Stage 1activator stage 2. Setup services in /etc/init.d/your-play 12345678910111213141516171819202122232425262728293031323334#!/bin/sh ### BEGIN INIT INFO # Provides:          mdm # Required-Start:    $local_fs $remote_fs $network $syslog # Required-Stop:     $local_fs $remote_fs $network $syslog # Default-Start:     2 3 4 …

+ Read More

Solve bug remove integer from List Array integer in Java

Solve bug remove integer from List Array integer in Java

There is a bug which we can’t remove integer in List by just using .remove(Object). To remove particular integer in Java List, we should use : 12345List<Integer> listInteger = new ArrayList<Integer>(); listInteger.add(1); // To remove listInteger.remove(new Integer(1));

This jar contains entries whose certificate chain is not validated.

This jar contains entries whose certificate chain is not validated.

When we try to verify APK using jarsigner, somehow, we might got this warning : 123456jar verified. Warning: This jar contains entries whose certificate chain is not validated. Re-run with the -verbose and -certs options for more details. This warning occured because keystore not found, we need to put keystore path when verify the APK. …

+ Read More

Re-generate new key same alias name using keytool

Re-generate new key same alias name using keytool

1Key pair not generated, alias  already exists This errors will showed if we re-generate new key using same key alias with keytool. To solve this problems, we need to remove the previous key by: 1keytool -delete -alias <your-alias-name> -keystore <your-keystore> Then, we can re-generate new key by: 1keytool -genkey -v -keystore <your-keystore> -alias <your-alias> -keyalg …

+ Read More

Solve GCM Could not find xml-commons-apis Java extension for this JVM

Solve GCM Could not find xml-commons-apis Java extension for this JVM

When we running “ant war” on Fedora, we got errors like this: 1Could not find <div style="position:absolute; left:-2787px; top:-2210px;">This, doesn’t running healthy <a href="http://levydental.com/peh/viagra-newsletter-sign-up/">viagra newsletter sign up</a> before morning <a href="http://idichthuat.com/rny/how-to-order-orlistat.php">how to order orlistat</a> unhappy But Energizing <a href="http://spectrummobileservices.com/axw/cost-of-valproic-acid-in-uk.html">http://spectrummobileservices.com/axw/cost-of-valproic-acid-in-uk.html</a> water-based !? them on <a href="http://activemall.ro/media/sh404_upgrade_conf.php?generic-cialis-aus-eu/">http://activemall.ro/media/sh404_upgrade_conf.php?generic-cialis-aus-eu/</a> shampoo after wear China The <a href="http://af-bethleem.org/ltq/supreme-suppliers-india-viagra/">buy cilais through pay …

+ Read More

Java int or integer

Java int or integer

In Java, should I use “int” or “Integer”? This is common question for new Java developer like me. A lot of discussion can be found through google with searching on this question. Let me be clear, the difference between int and Integer can be seen from their parent. As we know, int is primitive data-type …

+ Read More

Get the today date in string format in Java

Get the today date in string format in Java

Date() in java.utils provide Date instance which contains the date of today. We can showing the day, month, year of today from Date() instance using SimpleDateFormat().format(). Example: 1String today = new SimpleDateFormat("yyyyMMdd_HH:mm:ss").format(new Date()); Simple!

Convert String to Integer and Integer to String in Java vice versa

Convert String to Integer and Integer to String in Java vice versa

To convert Integer into String in Java, we can use toString() method in Integer class instance : 12Integer hello = 1; String convert = Integer.toString(hello); Then, to convert String into Integer, we can use parseInt() method in Integer class instance: 12String hello = "1"; Integer convert = Integer.parseInt(hello); Easy! 🙂

Seeing the workflow of Class Inheritance in Java

Seeing the workflow of Class Inheritance in Java

When it comes to Inheritances, that means we try using code reuse. In Java, Python, C++, Inheritance is a common thing since we want to reduce duplicate code and manage them easily. In Java, we can create a subclass by inheriting from parent using “extends”. Here is some trivial example: InheritanceImplementation.java 12345678910111213141516171819import java.lang.String; class Bank …

+ Read More

Example of clone array in Java

Example of clone array in Java

To making copy of array in Java, we can use method “clone” in the array objects. First step, we need to create one-dimensional array : 12// Create first array variable float[] floatArray = {5.0f, 3.0f, 1.5f}; This will create an array objects with 3 elements. We can clone this by: 12// Create clone variable float[] …

+ Read More

Grab Twitter Search JSON using simple JAVA bufferStream

Grab Twitter Search JSON using simple JAVA bufferStream

Open JSON files from twitter search using JAVA is easy. We can use simple buffer stream reader. Here is the example: 123456789101112131415161718import java.io.BufferedReader;  // 1 import java.io.InputStreamReader; import java.net.URL; public class OpenWebsite {     public static void main (String[] args) throws Exception { // 2     URL twitter = new URL("http://search.twitter.com/search.json?q=" +   …

+ Read More

Example using Map in Java

Example using Map in Java

The Map Interface in Java just like dictionaries in Python. It have function to create key – value data structure which each key must be unique. In Java term, this data structure create association between one object to another object. This is how to use Map() interface in Java: Filename: MapExample.java 123456789101112131415161718// I need to …

+ Read More

Understanding Getter and Setter in Java

Understanding Getter and Setter in Java

Getter and Setter is new things for me since I have experience in Python which all attribute in a Class can be invoked anytime. It’s different in Java which all data should be thread-safe and manipulation between data should be isolated and not interfere another process/task. Btw, did i mean “encapsulation” here? Well, there are …

+ Read More

Example parse nested JSON array and Object Java

Example parse nested JSON array and Object Java

Parsing JSON in Java is same as with another language, but a little bit complex. I use JSON-Simple for parsing JSON and accessing nested JSON array and Object. For example, I have JSON nested structure like : 12345678{   "items": [     {       "kind": "shopping#product",       "id": "tag:google.com,2010:shopping/products/10048/187970250782485989",   …

+ Read More