Pacific-Design.com

    
Home Index

1. Java

2. Delete

Java / Delete /

Java Environment

    - CLASSPATH: "$(find lib/ -name '*.jar' | xargs echo | tr ' ' ':')"
    - JAVA_HOME: "/usr/local/jdk1.8.0_111/"
    - JVM_ARGS: '"-Xmx256M -Xms256M"'

Bash Multi Command for Java

#!/bin/bash
#--------------------------------------------------------------------------------------------------------#
if [ -z "$1" ]; then
    mvn clean compile assembly:single

elif [ "$1" == "h" ] 2>/dev/null; then
    echo "+---------------------------------------------------+"
    echo "|  ./run.sh 0 -- mvn clean install                  |"
    echo "|  ./run.sh h -- Help                               |"
    echo "|  ./run.sh 1 -- Channel Day Day                    |"
    echo "|  ./run.sh 2 -- Channel Video Views                |"
    echo "+---------------------------------------------------+"
#--------------------------------------------------------------------------------------------------------#
else
    java -cp target/youtube-analytics-1.0.0-jar-with-dependencies.jar fresno.youtube.analytics.App $1  
fi
#--------------------------------------------------------------------------------------------------------#

Java Virtual Machine

                             +-----------+
                             |    JVM    |
                             +-----------+

     +--------------+   +--------------------+   +------------------+  
     | Class Loader |   | Byte Code Verifier |   | Security Manager | 
     +--------------+   +--------------------+   +------------------+ 

             +------------------+      +------------------+
             | Execution Engine |      | Garabe Collector |
             +------------------+      +------------------+
                                        ( Mark and Sweep )
             

JVM Memory

                        +-----------+
                        |    JVM    |
                        +-----------+

      +-------------+                  +-------------+
      |   Stack     |                  |    Heap     |
      +-------------+                  +-------------+
      |   Object    |                  |   ALL New   |
      |  Reference  |----------------->|   Objects   |
      |             |                  |             |
      +-------------+                  +-------------+

Java Just-In-Time compilation

Java Environment

import java.util.Map;

public class Main {

    public static void main(String args[]) throws InterruptedException {

        Map<String, String> env = System.getenv();
        
        for (String envName : env.keySet()) {
            System.out.format("ENV{%s} = %s%n", envName, env.get(envName));
        }
    }
}

Static members are the ones that are associated with the class and not with objects created from the class.

Java - Maven


# Run all test under AppTest class 
$ mvn -Dtest=AppTest test
 
# Run single unit test 
$ mvn -Dtest=AppTest#testApp test
 


package com.myhealthcare.util;                

import java.util.Map;
import junit.framework.Assert;
import org.junit.Test;

public class AppTest {

    @Test
    public void testApp() {

        System.out.println("AppTest:testApp");
        Assert.assertNull(null);
    }   
}

Maven Examples Test


Garbage Collection Tuning

$ jstat -gcutil 21719 1s
S0    S1    E    O    P    YGC    YGCT    FGC    FGCT GCT
48.66 0.00 48.10 49.70 77.45 3428 172.623 3 59.050 231.673
48.66 0.00 48.10 49.70 77.45 3428 172.623 3 59.050 231.673

References:

  1. http://www.java-tips.org/java-se-tips/java.lang/binary-search-tree-implementation-in-java.html
  2. CoderPad.IO - Java programming over HTML
  3. http://www.abilityfirst.co.uk/books