Quantcast
Channel: Developers Corner
Viewing all articles
Browse latest Browse all 43

Java Tutorial - Part 1

$
0
0
This article simulate what you will go through in the first day of job. The ultimate goal of the first day is to setup your working environment.

Prerequisite

  • 2 hands, 10 fingers
  • 2 eyes
  • 1 computer
  • 1 functional brain.


Setup environment

1. Download Java
  • Create one folder named "java" to store all your related development stuffs. In my computer, it is E:\java. If you use Linux or Mac, can set it to "~/java"
  • Download latest jdk version (currently v1.7.0_51). Install it to "java/jdk1.7.0_51". It is advisable to avoid extracting to "C:\Program Files" because this folder name has space. Please remember to keep the jdk version number in folder name because it is likely that we will need to have multiple jdk versions in the future. 
2. Download Maven 
  • Go to http://maven.apache.org/download.cgi and follow the instructions to install Maven. As above, please do not put Maven in your program files folder. I would recommend to put it in "java\apache-maven-3.2.1".
3. Download Tomcat
4. Download IDE
  • There are 3 well-known IDEs and all of them are perfectly fit for java development: Eclipse, Netbean and IntelliJ. If you have never heard about them I would say Eclipse is like Linux, NetBean and IntelliJ are like Windows . Eclipse is developed by community, difficult to configure but very customizable. This tutorial will use Eclipse as the default IDE. 
  • Create folder "java/workspace". Start Eclipse, it will ask for workspace folder. Please point to the folder we just created.

Discussion & Thinking 

  • Many of the popular tools and applications need JAVA_HOME to find out JRE or JDK to launch Java process. This practice is preferred over calling java from command line so that it is possible to have JRE available at system path for general use and JDK is for development. In case you need to use different version of JDK for different process, setting JAVA_HOME for each console is easier than modifying system path.  

  • Can take a look at mvn.bat or mvn in "java/apache-maven-3.2.1/bin" folder. Maven use the JDK/JRE as specified by JAVA_HOME.

  • Take a look at file eclipse.ini in the eclipse folder. This is the configuration file for eclipse. The default memory setup for Eclipse is a bit low, you can set to higher value if your computer have more Ram and you are going to develop more than one project. This is my setting
-Xms128m
-Xmx512m
-XX:MaxPermSize=256m
  • Open Eclipse, let navigate to Help -> About Eclipse -> Installation Detail -> Configuration. Verify that your memory configuration in the earlier step really take effect. 

Viewing all articles
Browse latest Browse all 43

Trending Articles