Wednesday, 30 October 2013

Before you can start to develop Java applications or webapps you have to install the JDK (the Java SE Development Kit).

The JDK is a development environment for building applications, applets, and components using the Java programming language.
The JDK includes tools useful for developing and testing programs written in the Java programming language and running on the Java platform.

On most systems Java is preinstalled, but only the Runtime Environment (JRE). The Runtime Environment lacks developer tools like the Java compiler "javac".
To see if and which Java environment is installed, execute "java -version" on the command line. Example (Linux Mint):
# java -version
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.13.04.2)
OpenJDK Server VM (build 23.7-b01, mixed mode)
This tells us, that the OpenJDK Runtime Environment is installed. OpenJDK is an open source implementation of Java. The original Java Company was Sun Microsystems and now Oracle. Oracle offers the market leader JDK, which we are going to install now.

Specification

Installation

The following installation guide may differ in JDK versions between different systems, but even if version is outdated the installation process should be still the same.

Windows

  • Execute EXE-File
  • Wizard:
    • Accept License Agreement
    • Install all components (Java DB not needed, but is only 25 MB...)
    • Target directories (defaults, don't change anything), e.g.:
      Development Tools: C:\Program Files\Java\jdk1.6.0_13\
      Demos and Samples: C:\Program Files\Java\jdk1.6.0_13\
      Source Code: C:\Program Files\Java\jdk1.6.0_13\
      Public JRE: C:\Program Files\Java\jre6\
      Java DB: C:\Program Files\Sun\JavaDB\
  • After installation a popup appears, which wants you to register. You don't need to do this.

Linux

Ubuntu

SUN JDK 6
  • Execute Synaptic package manager
  • Install "sun-java6-jdk"
  • Agree to license shown in dialog
Downloaded Oracle JDK
Unpack the downloaded TAR.GZ-package into a suitable directory (as root):
# mkdir -p /usr/lib/jvm
# cd /usr/lib/jvm/
# tar xvfz /home/ralf/Downloads/jdk-7u45-linux-i586.tar.gz
# ls -al
total 52
drwxr-xr-x   6 root root  4096 Okt 30 17:08 .
drwxr-xr-x 180 root root 28672 Okt 28 22:45 ..
lrwxrwxrwx   1 root root    23 Okt 28 22:15 default-java -> java-1.7.0-openjdk-i386
lrwxrwxrwx   1 root root    19 Okt 28 22:15 java-1.7.0-openjdk-i386 -> java-7-openjdk-i386
-rw-r--r--   1 root root  2396 Jul  3 21:59 .java-1.7.0-openjdk-i386.jinfo
drwxr-xr-x   5 root root  4096 Apr 25  2013 java-6-openjdk-i386
drwxr-xr-x   3 root root  4096 Apr 25  2013 java-7-openjdk-common
drwxr-xr-x   5 root root  4096 Apr 25  2013 java-7-openjdk-i386
drwxr-xr-x   8 uucp  143  4096 Okt  8 15:07 jdk1.7.0_45
Install the executables as default (with very high priority, e.g. 2000) (as root):
# sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0_45/bin/java" 2000
update-alternatives: using /usr/lib/jvm/jdk1.7.0_45/bin/java to provide /usr/bin/java (java) in auto mode
# sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0_45/bin/javac" 2000
update-alternatives: using /usr/lib/jvm/jdk1.7.0_45/bin/javac to provide /usr/bin/javac (javac) in auto mode
# sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0_45/bin/javaws" 2000
update-alternatives: using /usr/lib/jvm/jdk1.7.0_45/bin/javaws to provide /usr/bin/javaws (javaws) in auto mode
# sudo update-alternatives --install "/usr/bin/jar" "jar" "/usr/lib/jvm/jdk1.7.0_45/bin/jar" 2000
update-alternatives: using /usr/lib/jvm/jdk1.7.0_45/bin/jar to provide /usr/bin/jar (jar) in auto mode

Debian

(# apt-cache search jdk –n)
(# apt-get install sun-java6-jdk –s)
# apt-get install sun-java6-jdk

Slackware based Distros

$ su -
Password: 
# cd /opt/
# ls -al
total 4
drwxr-xr-x  2 root root    6 Jun 10  2007 ./
drwxr-xr-x 20 root root 4096 Oct 31 22:07 ../
# tar xvfz /home/ralf/Downloads/jdk-7u45-linux-i586.tar.gz
...
# ls -al
total 8
drwxr-xr-x  3 root root   24 Oct 31 22:11 ./
drwxr-xr-x 20 root root 4096 Oct 31 22:07 ../
drwxr-xr-x  8 uucp  143 4096 Oct  8 15:07 jdk1.7.0_45/

Configuration

Add JAVA_HOME environment variable

Windows

  • Start - Settings - Control Panel - System - Advanced - Environment Variables
  • System variables - New: JAVA_HOME = C:\Program Files\Java\jdk1.6.0_13

Ubuntu Linux

# nano /etc/environment
...
JAVA_HOME="/usr/lib/jvm/java-6-sun/"
...
# source /etc/environment

Other Linux Distro

Linux Mint:
# nano /etc/environment
...
JAVA_HOME="/usr/lib/jvm/jdk1.7.0_45"
...
# source /etc/environment

Slackware based Distros

# vi /etc/profile.d/jdk.csh
#!/bin/csh

setenv JAVA_HOME /opt/jdk1.7.0_45
setenv MANPATH ${MANPATH}:${JAVA_HOME}/man
setenv PATH ${PATH}:${JAVA_HOME}/bin
# vi /etc/profile.d/jdk.sh
#!/bin/sh

export JAVA_HOME=/opt/jdk1.7.0_45
export MANPATH="$MANPATH:$JAVA_HOME/man"
export PATH="$PATH:$JAVA_HOME/bin"
# chmod +x /etc/profile.d/jdk.sh
# chmod +x /etc/profile.d/jdk.csh
# chmod -x /etc/profile.d/openjre.sh
# chmod -x /etc/profile.d/openjre.csh

Test

Windows

Open a new command prompt window (Start - Programs - Accessoires - Command Prompt)
C:\>java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)
C:\>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0_13

Ubuntu

Open a new terminal
$ java -version
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Server VM (build 14.2-b01, mixed mode)
$ echo $JAVA_HOME
/usr/lib/jvm/java-6-sun/

Other Distro

# java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) Server VM (build 24.45-b08, mixed mode)
$ echo $JAVA_HOME
/usr/lib/jvm/jdk1.7.0_45

Troubleshooting

Download timeout because of proxy

Problem: Timeouts caused by proxy (download takes too long).
Solution Debian Linux:
  • Download "sun-java6"-packages manually onto your desktop system with browser (e.g. from http://ftp.hosteurope.de/pub/linux/debian/)
  • Copy DEB-packages to server
  • Install the packages using "dpkg –i":
    # dpkg –i sun-java6-bin_6-13-1_i386.deb
    # dpkg –i sun-java6-jdk_6-13-1_i386.deb
    # dpkg –i sun-java6-jre_6-13-1_all.deb
    

39 comments:

  1. Very nice post , thanks for sharing this post with us and gave us a good information regarding java

    ReplyDelete
  2. Thanks for your informative article on Java. It is most popular and reliable software development platform for creating mobile application. JAVA Course in Chennai

    ReplyDelete
  3. Thanks for your informative article on Java . Thank share posts very detailed !

    key :nap the dien thoai - khuyến mại vinaphone - nap the zing me

    ReplyDelete
  4. This is certainly one of the most valuable article. Great tips from beginning to till end. Lot of information are available here.Super article.
    Phonegap Training in chennai | Phonegap Training chennai | Phonegap course in chennai | Phonegap course chennai


    ReplyDelete
  5. I learn a worthful information by this training.This makes very helpful for future reference.All the doubts are very clearly explained in this article.Thank you very much.
    VMWare Training in chennai | VMWare Training chennai | VMWare course in chennai

    ReplyDelete
  6. This aticle says the importance of using this application is very great.Now i clearly say what is the overall performance and the uses of the application.
    Cloud Computing Training in chennai | Cloud Computing Training chennai | Cloud Computing Course in chennai | Cloud Computing Course chennai


    ReplyDelete
  7. The information you have given here are most worthy for me. I have implemented in my training program as well, thanks for sharing.

    Hadoop Training Chennai
    Hadoop Training in Chennai

    ReplyDelete
  8. Thanks for sharing your informative article on Hive ODBC Driver. Your article is very descriptive and assists me to learn whole concept in detail. Hadoop Training in Chennai

    ReplyDelete
  9. This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.
    Regards,
    Informatica training center in Chennai|Informatica training chennai|Informatica course in Chennai

    ReplyDelete
  10. There are lots of information about latest technology and how to get trained in them, like Best Hadoop Training In Chennai in Chennai have spread around the web, but this is a unique one according to me. The strategy you have updated here will make me to get trained in future technologies Hadoop Training in Chennai By the way you are running a great blog. Thanks for sharing this blogs..

    ReplyDelete
  11. I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
    SalesForce Training in Chennai

    ReplyDelete
  12. Pretty article! I found some useful information in your blog, it was awesome to read,thanks for sharing this great content to my vision, keep sharing..
    Unix Training In Chennai

    ReplyDelete
  13. This information is impressive..I am inspired with your post writing style & how continuously you describe this topic. After reading your post,thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic
    Android Training In Chennai In Chennai

    ReplyDelete
  14. SAP Training in Chennai
    This post is really nice and informative. The explanation given is really comprehensive and informative..

    ReplyDelete
  15. Oracle Training in chennai
    Thanks for sharing such a great information..Its really nice and informative..

    ReplyDelete
  16. Selenium Training in Chennai
    Wonderful blog.. Thanks for sharing informative blog.. its very useful to me..

    ReplyDelete
  17. Data warehousing Training in Chennai
    I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly..

    ReplyDelete
  18. Whatever we gathered information from the blogs, we should implement that in practically then only we can understand that exact thing clearly, but it’s no need to do it, because you have explained the concepts very well. It was crystal clear, keep sharing..
    Websphere Training in Chennai

    ReplyDelete
  19. Oracle DBA Training in Chennai
    Thanks for sharing this informative blog. I did Oracle DBA Certification in Greens Technology at Adyar. This is really useful for me to make a bright career..

    ReplyDelete
  20. Oracle Training in chennai | Oracle D2K Training In chennai
    This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic..

    ReplyDelete
  21. Thanks for Information Oracle Apps Technical is a collection of a bunch of collected applications like accounts payables, purchasing, inventory, accounts receivables, human resources, order management, general ledger and fixed assets, etc which have its own functionality for serving the business
    Oracle Apps Training In Chennai

    ReplyDelete
  22. This comment has been removed by the author.

    ReplyDelete
  23. This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic..
    Selenium Training in Chennai | QTP Training in Chennai

    ReplyDelete
  24. Thanks for sharing the pretty post, if you focus the certification training to enhance your skill for attaining good job in IT industry, for that you have to take the valuable certification training of SAS for your career growth.
    Regards,
    sas training in Chennai|sas course in Chennai|sas training institutes in Chennai

    ReplyDelete
  25. Wow! It was the best article , actually you have posted something useful than others, because I read many articles related to this basics of programming, but I only get impressed with your post only, keep posting.
    Regards,
    ccna course in Chennai|ccna training in Chennai|ccna training institute in Chennai

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  26. Really awesome blog. Your blog is really useful for me.
    Thanks for sharing this informative blog. Keep update your blog.
    Oracle Training In Chennai

    ReplyDelete
  27. Best Java Training Institute In ChennaiThis information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic..

    ReplyDelete
  28. Excellent post! keep sharing such a informative post.
    php training in chennai

    ReplyDelete
  29. Superb blog. I really enjoyed very much with this article here. Really its a amazing article i had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.
    Java Training in Chennai

    ReplyDelete
  30. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Android Training in Chennai
    Ios Training in Chennai

    ReplyDelete
  31. Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
    PEGA Training in Chennai

    ReplyDelete
  32. The Spring Framework is a lightweight framework for developing Java enterprise applications. It provides high performing, easily testable and reusable code. Spring handles the infrastructure as the underlying framework so that you can focus on your application.Spring is modular in design, thereby making creation, handling and linking of individual components so much easier. Spring implements Model View Container(MVC) design pattern.
    Spring 4 mvc hello world example

    ReplyDelete