Posts

Showing posts from 2013

Is the JVM a compiler or an interpreter?

First, let's have a clear idea of the following terms Javac is Java Compiler -- Compiles your Java code into Bytecode JVM is Java Virtual Machine -- Runs/ Interprets/ translates Bytecode into Native Machine Code JIT is Just In Time Compiler -- Compiles the given bytecode instruction sequence to machine code at run-time before executing it natively. It's main purpose is to do heavy optimizations in performance. So now, Let's find answers to your questions.. 1)JVM: is it a compiler or an interpreter? -- Ans: Interpreter 2)what about JIT compiler that exist inside the JVM? -- Ans: If you read this reply completely, you probably know it now 3)what exactly is the JVM? -- Ans: JVM is a virtual platform that resides on your RAMIts component, Class loader loads the .class file into the RAMThe Byte code Verifier component in JVM checks if there are any access restriction violations in your code. (This is one of the principle reasons why java is secure)Next, the Execution Engine compone…

Example AES technology

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.commons.io.IOUtils;

public class Test {

    /**
     * @param args
     */
    public static void main(String[] args) {
          System.out.println("Listing all table name in Database!");
          Connection con = null;
          String url = "jdbc:mysql://localhost:3306/";
          String db = "test";
          String driver = "com.mysql.jdbc.Driver";
          String user = "root";
          String pass = "root";
          String name="";
          String address="";
          try{
              Class.forName(driver);
              con = DriverManager.getConnection(url+db, user, pass);
              try{
                  System.out.println("Table name:");
                  Statement st = con.createStatement();
                  Resu…

Heap size for JVM

Two JVM options are often used to tune JVM heap size: -Xmx for maximum heap size, and -Xms for initial heap size. Here are some common mistakes made by developers while using them:
Missing m, M, g or G at the end (they are case insensitive). For example,

java -Xmx128 BigApp java.lang.OutOfMemoryError: Java heap space The correct command should be: java -Xmx128m BigApp. To be precise, -Xmx128 is a valid setting for very small apps, like HelloWorld. But in real life, I guess you really mean -Xmx128m

Extra space in JVM options, or incorrectly use =. For example,

java -Xmx 128m BigApp Invalid maximum heap size: -Xmx Could not create the Java virtual machine. java -Xmx=512m HelloWorld Invalid maximum heap size: -Xmx=512m Could not create the Java virtual machine. The correct command should be java -Xmx128m BigApp, with no whitespace nor =. -X options are different than -Dkey=value system properties, where = is used.

Only setting -Xms JVM option and its value is greater than the default maxim…

Encrypt MySQL data using AES techniques

CREATETABLE`user` ( `id` BIGINTUNSIGNED NOTNULLAUTO_INCREMENT , `first_name` VARBINARY(100) NULL, `address` VARBINARY(200) NOTNULL, PRIMARYKEY(`id`) ENGINE = InnoDB DEFAULTCHARACTERSET= utf8 COLLATE= utf8_general_ci You may be expected the table structure should be:









CREATETABLE`user` ( `id` BIGINTUNSIGNED NOTNULLAUTO_INCREMENT , `first_name` VARCHAR(50) NULL, `address` VARCHAR(100) NOTNULL, PRIMARYKEY(`id`) ENGINE = InnoDB DEFAULTCHARACTERSET= utf8 COLLATE= utf8_general_ci To encrypt & decrypt mysql data we will use AES_ENCRYPT() and AES_DECRYPT() functions. These functions used the official AES (Advanced Encryption Standard) algorithm & encode data with a 128-bit key length. 128 bits is much faster and secure enough for most purposes.

Why we used VARBINARY data type instead of VARCHAR:
Because AES_ENCRYPT() encrypts a string and returns a binary string. AES_DECRYPT() decrypts the encrypted string and returns the original string.
AES is a block-level algorithm. So when data encrypted it …

How to Share Your 3G/4G Data Card Over Wifi with Ubuntu Linux