Window > Preferences > Java > Installed JREs > Standart VM > JRE home
choose
C:\Program Files (x86)\Java\jdk1.8.0_31
C:\Users\jupiter>java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) Client VM (build 25.31-b07, mixed mode)
Showing posts with label java. Show all posts
Showing posts with label java. Show all posts
Monday, March 9, 2015
Thursday, September 11, 2014
how to install tomcat
PLATFORM
windows 7 family edition 64-bit
jdk 1.7.0
tomcat 7.0.26 (64-bit edition)
go to apache tomcat website and download tomcat 7.0
http://tomcat.apache.org/
download 64-bit Windows zip file as we try to install tomcat 7.0.26 on windows 7 64-bit system
unzip apache-tomcat-7.0.26-windows-x64.zip
this is how the folder looks like after unzipping
C:\Downloads\apache-tomcat-7.0.26-windows-x64\apache-tomcat-7.0.26\bin
If you click startup.bat file to start tomcat IT WILL NOT RUN
C:\Downloads\apache-tomcat-7.0.26-windows-x64\apache-tomcat-7.0.26\bin\startup.bat
To get tomcat running,first run command prompt
Then with cd command go to directory
cd C:\Downloads\apache-tomcat-7.0.26-windows-x64\apache-tomcat-7.0.26\bin
Run startup.bat in the command prompt
C:\Downloads\apache-tomcat-7.0.26-windows-x64\apache-tomcat-7.0.26\bin>startup.bat
Then type on firefox
http://localhost:8080
Server Status" and "Manager App" interfaces require manager-gui role and "Host Manager" requires admin-gui role.
add these lines and restart tomcat if it works.
C:\Downloads\apache-tomcat\conf \tomcat-users.xml
<role rolename="manager-gui,admin-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui,admin-gui"/>
configure tomcat port.
C:\Downloads\apache-tomcat\conf\server.xml
<Connector port="5555" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
This file sets java_home manually and runs tomcat on the folder mentioned.
contents of "tomcat start.cmd" file.
@echo off
SET JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_31
SET CATALINA_HOME=C:\Downloads\apache-tomcat
C:\Downloads\apache-tomcat\bin\startup.bat
run "tomcat start.cmd" on folder
C:\Downloads\ciroot
test tomcat whether it runs
tomcat runs on http://localhost:8080/
windows 7 family edition 64-bit
jdk 1.7.0
tomcat 7.0.26 (64-bit edition)
go to apache tomcat website and download tomcat 7.0
http://tomcat.apache.org/
download 64-bit Windows zip file as we try to install tomcat 7.0.26 on windows 7 64-bit system
unzip apache-tomcat-7.0.26-windows-x64.zip
this is how the folder looks like after unzipping
C:\Downloads\apache-tomcat-7.0.26-windows-x64\apache-tomcat-7.0.26\bin
If you click startup.bat file to start tomcat IT WILL NOT RUN
C:\Downloads\apache-tomcat-7.0.26-windows-x64\apache-tomcat-7.0.26\bin\startup.bat
To get tomcat running,first run command prompt
Then with cd command go to directory
cd C:\Downloads\apache-tomcat-7.0.26-windows-x64\apache-tomcat-7.0.26\bin
Run startup.bat in the command prompt
C:\Downloads\apache-tomcat-7.0.26-windows-x64\apache-tomcat-7.0.26\bin>startup.bat
Then type on firefox
http://localhost:8080
Server Status" and "Manager App" interfaces require manager-gui role and "Host Manager" requires admin-gui role.
add these lines and restart tomcat if it works.
C:\Downloads\apache-tomcat\conf \tomcat-users.xml
<role rolename="manager-gui,admin-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui,admin-gui"/>
configure tomcat port.
C:\Downloads\apache-tomcat\conf\server.xml
<Connector port="5555" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
This file sets java_home manually and runs tomcat on the folder mentioned.
contents of "tomcat start.cmd" file.
@echo off
SET JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_31
SET CATALINA_HOME=C:\Downloads\apache-tomcat
C:\Downloads\apache-tomcat\bin\startup.bat
run "tomcat start.cmd" on folder
C:\Downloads\ciroot
test tomcat whether it runs
tomcat runs on http://localhost:8080/
how to spring-framework-3.1.0. and eclipse indigo
- PLATFORM
*windows 7 family edition 64-bit
*download Java Platform, Standard Edition
Java SE 7u3
jdk-7u3-windows-i586.exe
www.oracle.com
*download Java EE 6 Development Kit Bundles without JDK
Java EE 6 SDK Update 4
java_ee_sdk-6u4-windows-ml.exe
www.oracle.com
*download tomcat 7.0.26 (32-bit edition)
apache-tomcat-7.0.26-windows-x86.zip
http://tomcat.apache.org
*download Eclipse IDE for Java EE Developers
eclipse indigo package 32 bit
eclipse-jee-indigo-SR2-win32.zip
http://www.eclipse.org
*download Spring Framework 3.1.0.RELEASE
spring-framework-3.1.0.RELEASE-with-docs.zip
http://www.springsource.org/download
Because of the problems linked to whether 64-bit or 32-bit software should be used,even though I use 64-bit I prefer 32-bit software so that I don't risk having compatibility issues
@there are two types of containers in spring: applicationcontext and beanfactory.
applicationcontext is used in this example
@ create a new project eg "tester"
Eclipse-New-Java Project
@righ click on file "tester"
java build path-libraries-add external jars
@add all files in "spring-framework-3.1.0.RELEASE\dist"
@add file "spring-framework-3.1.0.RELEASE\projects\spring-build\lib\ivy\commons-logging.jar"
@create a new package
com.edu4java.spring.tutorial3
@create new java class Hello.java
@create Main.java class that uses Hello.java
@create context.xml by using this pdf file "spring-framework-3.1.0.RELEASE\docs\spring-framework-reference\pdf\spring-framework-reference.pdf"
References:
http://www.youtube.com/watch?v=ZwMwfGNrRtE&feature=related
how to spring aop with eclipse indigo
PLATFORM
*windows 7 family edition 64-bit
ps:Because of the problems linked to whether 64-bit or 32-bit software should be used,even though I use 64-bit I prefer 32-bit software so that I don't risk having compatibility issues
*download Java Platform, Standard Edition
Java SE 7u3
jdk-7u3-windows-i586.exe
www.oracle.com
*download Java EE 6 Development Kit Bundles without JDK
Java EE 6 SDK Update 4
java_ee_sdk-6u4-windows-ml.exe
www.oracle.com
*download Eclipse IDE for Java EE Developers
eclipse indigo package 32 bit
eclipse-jee-indigo-SR2-win32.zip
http://www.eclipse.org
*download Spring Framework 3.1.0.RELEASE
spring-framework-3.1.0.RELEASE-with-docs.zip
http://www.springsource.org/download
*download aspectj-1.6.12.jar
http://www.eclipse.org/aspectj/downloads.php
What is AspectJ?
AspectJ(tm) is a simple and practical extension to the Java(tm) programming language that adds to Java aspect-oriented programming (AOP) capabilities. AOP allows developers to reap the benefits of modularity for concerns that cut across the natural units of modularity. In object-oriented programs like Java, the natural unit of modularity is the class. In AspectJ, aspects modularize concerns that affect more than one class.
*download aopalliance.zip
The AOP Alliance project is a joint open-source project between several software engineering people who are interested in AOP and Java
AOP Alliance: http://aopalliance.sourceforge.net/
*download cglib-2.2.2.jar
cglib is a powerful, high performance and quality Code Generation Library, It is used to extend JAVA classes and implements interfaces at runtime.
CGILIB: http://cglib.sourceforge.net/
*download asm-3.3.1.jar (asm-4.0-bin.zip caused compatability problems and had to remove)
ASM is an all purpose Java bytecode manipulation and analysis framework. It can be used to modify existing classes or dynamically generate classes, directly in binary form
http://asm.ow2.org/
*windows 7 family edition 64-bit
ps:Because of the problems linked to whether 64-bit or 32-bit software should be used,even though I use 64-bit I prefer 32-bit software so that I don't risk having compatibility issues
*download Java Platform, Standard Edition
Java SE 7u3
jdk-7u3-windows-i586.exe
www.oracle.com
*download Java EE 6 Development Kit Bundles without JDK
Java EE 6 SDK Update 4
java_ee_sdk-6u4-windows-ml.exe
www.oracle.com
*download Eclipse IDE for Java EE Developers
eclipse indigo package 32 bit
eclipse-jee-indigo-SR2-win32.zip
http://www.eclipse.org
*download Spring Framework 3.1.0.RELEASE
spring-framework-3.1.0.RELEASE-with-docs.zip
http://www.springsource.org/download
*download aspectj-1.6.12.jar
http://www.eclipse.org/aspectj/downloads.php
What is AspectJ?
AspectJ(tm) is a simple and practical extension to the Java(tm) programming language that adds to Java aspect-oriented programming (AOP) capabilities. AOP allows developers to reap the benefits of modularity for concerns that cut across the natural units of modularity. In object-oriented programs like Java, the natural unit of modularity is the class. In AspectJ, aspects modularize concerns that affect more than one class.
*download aopalliance.zip
The AOP Alliance project is a joint open-source project between several software engineering people who are interested in AOP and Java
AOP Alliance: http://aopalliance.sourceforge.net/
*download cglib-2.2.2.jar
cglib is a powerful, high performance and quality Code Generation Library, It is used to extend JAVA classes and implements interfaces at runtime.
CGILIB: http://cglib.sourceforge.net/
*download asm-3.3.1.jar (asm-4.0-bin.zip caused compatability problems and had to remove)
ASM is an all purpose Java bytecode manipulation and analysis framework. It can be used to modify existing classes or dynamically generate classes, directly in binary form
http://asm.ow2.org/
how to java enterprise application
there are 3 ways of implementing enterprise applications with java. This list can be updated or corrected.
1-licensed j2ee servers -weblogic,websphere,oracle application server
2-open source j2ee containers - jboss,glassfish,tomcat,openejb,activemq
3-spring framework + opensource servlet/jsp engine -tomcat,jetty,resin
1-licensed j2ee servers -weblogic,websphere,oracle application server
2-open source j2ee containers - jboss,glassfish,tomcat,openejb,activemq
3-spring framework + opensource servlet/jsp engine -tomcat,jetty,resin
Tuesday, April 29, 2014
Java 8 features : default methods
Functional interface can not have more than one abstract method but it can have more than one default methods.
public interface DefaultInterface1 {
public void printMessage1();
default void printMessage2(){
System.out.println("default method test1");
}
default void printMessage3(){
System.out.println("default method test2");
}
}
you can either use annotations
@FunctionalInterface
public interface DefaultInterface1 {
public void printMessage1();
default void printMessage2(){
System.out.println("default method test1");
}
default void printMessage3(){
System.out.println("default method test2");
}
}
public class DefaultInterface1Test implements DefaultInterface1 {
public static void main(String[] args) {
DefaultInterface1Test di1=new DefaultInterface1Test();
di1.printMessage1();
// default method test1
di1.printMessage2();
// default method test2
di1.printMessage3();
}
@Override
public void printMessage1() {
System.out.println("not default method");
}
}
public interface DefaultInterface1 {
public void printMessage1();
default void printMessage2(){
System.out.println("default method test1");
}
default void printMessage3(){
System.out.println("default method test2");
}
}
you can either use annotations
@FunctionalInterface
public interface DefaultInterface1 {
public void printMessage1();
default void printMessage2(){
System.out.println("default method test1");
}
default void printMessage3(){
System.out.println("default method test2");
}
}
public class DefaultInterface1Test implements DefaultInterface1 {
public static void main(String[] args) {
DefaultInterface1Test di1=new DefaultInterface1Test();
di1.printMessage1();
// default method test1
di1.printMessage2();
// default method test2
di1.printMessage3();
}
@Override
public void printMessage1() {
System.out.println("not default method");
}
}
Java 8 features : lambda expressions
Anonymous classes enable you to make your code more concise.
They enable you to declare and instantiate a class at the same time.
They are like local classes except that they do not have a name
public interface FunctionalInterface1 {
// Functional Interface by defining Single Abstract Method in interface.
public void printMessage();
}
public class FunctionalInterface1Test {
public static void main(String[] args) {
// anonymous inner class example
FunctionalInterface1 ft1=new FunctionalInterface1(){
public void printMessage(){
System.out.println("anonymous inner class example");
}
};
ft1.printMessage();
// lambda expression example
FunctionalInterface1 ft2=()->{
System.out.println("lambda test1");
System.out.println("lambda test2");
};
ft2.printMessage();
}
}
Functional interface can not have more than one abstract method but it can have more than one default methods.
You can use annotations for functional interfaces
@FunctionalInterface
public interface FunctionalInterface2 {
// Functional Interface by defining Single Abstract Method in interface.
public void printMessage();
// public void printMessage1();
}
if you uncomment printMessage1 it gives error below
Invalid '@FunctionalInterface' annotation; FunctionalInterface2 is not a functional interface
public class FunctionalInterface2Test {
public static void main(String[] args) {
FunctionalInterface2 fi1=new FunctionalInterface2() {
@Override
public void printMessage() {
System.out.println("anonymous inner class test1");
}
};
fi1.printMessage();
FunctionalInterface2 fi2=()->{
System.out.println("lambda expression test1");
};
fi2.printMessage();
}
}
Using functional interfaces with anonymous inner classes are a common pattern in Java
In addition to the EventListener classes, interfaces like Runnable and Comparator are used in a similar manner
Therefore, functional interfaces are leveraged for use with lambda expressions.
As Runnable is having Single Abstract Method, we can consider this as a Functional Interface and we can use Lambda expression
public class RunnableTest {
public static void main(String[] args) {
System.out.println("=== RunnableTest ===");
// Anonymous Runnable
Runnable r1 = new Runnable(){
@Override
public void run() {
System.out.println("anonymous works");
}
};
// Lambda Runnable
Runnable r2=()-> System.out.println("lambda works");
// Run em!
r1.run();
r2.run();
}
}
They enable you to declare and instantiate a class at the same time.
They are like local classes except that they do not have a name
public interface FunctionalInterface1 {
// Functional Interface by defining Single Abstract Method in interface.
public void printMessage();
}
public class FunctionalInterface1Test {
public static void main(String[] args) {
// anonymous inner class example
FunctionalInterface1 ft1=new FunctionalInterface1(){
public void printMessage(){
System.out.println("anonymous inner class example");
}
};
ft1.printMessage();
// lambda expression example
FunctionalInterface1 ft2=()->{
System.out.println("lambda test1");
System.out.println("lambda test2");
};
ft2.printMessage();
}
}
Functional interface can not have more than one abstract method but it can have more than one default methods.
You can use annotations for functional interfaces
@FunctionalInterface
public interface FunctionalInterface2 {
// Functional Interface by defining Single Abstract Method in interface.
public void printMessage();
// public void printMessage1();
}
if you uncomment printMessage1 it gives error below
Invalid '@FunctionalInterface' annotation; FunctionalInterface2 is not a functional interface
public class FunctionalInterface2Test {
public static void main(String[] args) {
FunctionalInterface2 fi1=new FunctionalInterface2() {
@Override
public void printMessage() {
System.out.println("anonymous inner class test1");
}
};
fi1.printMessage();
FunctionalInterface2 fi2=()->{
System.out.println("lambda expression test1");
};
fi2.printMessage();
}
}
Using functional interfaces with anonymous inner classes are a common pattern in Java
In addition to the EventListener classes, interfaces like Runnable and Comparator are used in a similar manner
Therefore, functional interfaces are leveraged for use with lambda expressions.
As Runnable is having Single Abstract Method, we can consider this as a Functional Interface and we can use Lambda expression
public class RunnableTest {
public static void main(String[] args) {
System.out.println("=== RunnableTest ===");
// Anonymous Runnable
Runnable r1 = new Runnable(){
@Override
public void run() {
System.out.println("anonymous works");
}
};
// Lambda Runnable
Runnable r2=()-> System.out.println("lambda works");
// Run em!
r1.run();
r2.run();
}
}
Wednesday, April 23, 2014
super() example
It’s legal to invoke "new" from within a constructor and to call
super() on a class with no explicit superclass.
public class Test1 {
static int count = 0;
Test1() {
while(count < 10)
new Test1(++count);
}
Test1(int x)
{
super();
}
public static void main(String[] args) {
new Test1();
new Test1(count);
System.out.println(count++);
}
}
outcome is 10 here.
super() on a class with no explicit superclass.
public class Test1 {
static int count = 0;
Test1() {
while(count < 10)
new Test1(++count);
}
Test1(int x)
{
super();
}
public static void main(String[] args) {
new Test1();
new Test1(count);
System.out.println(count++);
}
}
outcome is 10 here.
Subscribe to:
Posts (Atom)