//Hello world! Get taste of java in few simple steps.
Install jdk. We can download installer file(can skip step #3) or compressed tar file from Oracle.
Write helloworld program in file named "HelloWorld.java"
public class HelloWorld {
public static void main(String[] args){
System.out.println("Hello world! This is first step to learning Java");
}
}
Check/set if java/javac commands are known to system. i.e. is java path set correctly. In terminal/command prompt, simply try executing "javac" command. If error message is displayed like "'javac' is not recognized as an internal or external command, operable program or batch file.", then we need to add path of "bin" directory to environment variable "path". It can be done as follows(you may have installed/extracted jdk files in different folder; use same in below):
a. In windows command prompt - set PATH=%PATH%;C:\Program Files\Java\jdk1.8.0_361\bin
b. In Linux shell - export PATH=${PATH}:/opt/Java/jdk1.8.0_361/bin
Compile helloworld program
javac HelloWorld.java
Run helloworld program
java HelloWorld
FoExecutor : The Executor framework is a framework for standardizing invocation, scheduling, execution, and control of asynchronous tasks according to a set of execution policies. (ref: Oracle, StackOverFlow). read more
#Setups: default Java on centos
JAXB: schema-to-java, java-to-schema and all solution for java and xml developers.JAXB by ORACLE
#How To create jars : docs.oracle.com
javac -cp /opt/hadoop/hadoop-2.6.0/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.6.0.jar:/opt/hadoop/hadoop-2.6.0/share/hadoop/common/hadoop-common-2.6.0.jar:. com/ugam/hbaseex/mapred/MapRedDriver.java
jar -cvf /urs/hadoop-user/WordCounter.jar -C ./ com/ugam/hbaseex/mapred/*.class
# Forcefully delete any file/folder.
FileDeleteStrategy.FORCE.delete(<FILE_OBJECT>);
# Manually load properties from src/main/resources/application.properties file.
Properties properties = new Properties(); properties.load(getClass().getResourceAsStream("/application.properties"));
System.setProperties(properties);
Problem 1: Exception in thread "main" java.lang.Error: Can't find java.home ??
Sol : It was thrown by logger. as by mistake System.Properties were completely overridden instead of adding.
Problem 2: JPS lists some process Id with no Process information.
Sol : Deleted hsperf.* folders in /tmp/
Problem 3:Caused by: java.lang.SecurityException: class "javax.servlet.Filter"'s signer information does not match signer information of other classes in the same package
Soln: Solved by excluding javax.servlet from hbase and hadoop dependencies.
Problem 4: running multiple versions of java. /usr/bin/java linked to java7, and another application has dependency of java 8.
Soln: Invoke fresh shell> export JAVA_HOME pointing to desired java version folder (jdk1.8.0_161, in my case) > export PATH=$JAVA_HOME/bin:$PATH . Notable thing here is desired JAVA path is set first on PATH, hence environment will reach desired java version first.
TickerThread using Executor framework.
Thread pool implementation of Executor framework.
Example of byte representation of character in various character set.