Saturday, September 13, 2008

Javaize your Ubuntu

  • Installing Java

    1. Type
      sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk
      .

    2. Read and accept lisece of Sun.

    3. Now we should tell Ubuntu to regard the installed JVM as the default one:

      1. You need to edit a file called /etc/jvm. This file defines the default system JVM search order.

      2. The default system JVM is the first one available from top to bottom.

      3. Type
        $ gksudo gedit /etc/jvm
        so as to open it as root.

      4. The file contains:
        /usr/lib/jvm/java-gcj
        /usr/lib/jvm/ia32-java-1.5.0-sun
        /usr/lib/jvm/java-1.5.0-sun
        /usr

      5. Add
        /usr/lib/jvm/java-6-sun
        such that the file's contents become:
        /usr/lib/jvm/java-6-sun
        /usr/lib/jvm/java-gcj
        /usr/lib/jvm/ia32-java-1.5.0-sun
        /usr/lib/jvm/java-1.5.0-sun
        /usr

      6. Save and close the file.

  • Testing Java

  1. Type
    java -version
    output should be something like:
    java version "1.6.0_06"
    Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
    Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)

  2. Create a HelloWorld.java and save it in [certain_directory]

  3. Type
    javac [certain_directory/HelloWorld.java]

    • Nothing should be output.
    • In the the file "HelloWorld.class" must be generated.
    • Move the HelloWorld.class to [another_or_same_dir]

  4. Type
    java -classpath [another_or_same_dir] HelloWorld
  5. Note that that we have set the environmental variable: classpath to avoid the ClassNotFoudException
  6. The HelloWorld.class must be executed (run) and
    Hello World
    is to be printed.

  • Next step .. Eclipse

  • We have two options:

    VersionOption 1Option 2
    Eclipse versionInstalling Eclipse Callisto (3.2)Installing Eclipse Ganymede (3.4)
    AdvantageEnjoying the benefits of eclipse as a universe Ubuntu software package Making use of eclipse latest version and its new features.
    Procedures
    1. System -> Adminstration -> Synaptic Package Manager and enter Password
    2. Highlight the list-item "All" in the left list.
    3. Search for "eclipse".
    4. After it is found -> right click -> mark -> agree -> apply.
    5. Wait till finishing download and installation.
      1. Download eclipse for linux
      2. Copy paste the downloaded .gz file to your home folder
      3. Right click it -> Extract here
      4. Open the extracted folder (eclipse) and here is present the executable eclipse ganymede
      5. Note that the link I provided was to classic eclipse if you want to use the enterprise one or any other version check this

    6. Next step .. The standard widget toolkit (SWT)

    7. Remember that -after migration to Ubuntu- you need to find a replacement to any platform dependent component like JDk, JRE, Eclipse and SWT (which is not the case of either any of nebula widgets as they are based upon SWT, nor Swing GUI library as it is based on JDK and JRE nor Java ribbon which based upon SWT).
      I mean that all of those components will work fine on Ubuntu as well as any OS as long as the proper version of Java (JRE, JDK, JVM, SWT) is installed on the entire OS.
      1. From SWT home download SWT for linux
      2. Keep the downloaded zipped file in a known safe directory.
      3. Unzip it and copy the SWT.jar from it and paste in the directory of ur java project
      4. Refresh the project from eclipse and enjoy..

      5 comments:

      1. Great article with a funny title :D
        thanks for sharing...

        ReplyDelete
      2. Great guide , i did almost all of it except the SWT part.
        Thanks for ur Ubuntu tutorials ,, keep on man :)

        ReplyDelete
      3. La3eeeeeeeeeeeeeeeeeeeeeeeeeeeeeB KeBeeeeeeeeeeeeeeeeeeeeeeeeeeeeeR
        aweee aweee aweee waLLaHy :D:D:D

        ReplyDelete
      4. Thanks guys for sweet comments. If anyone wanna discuss the issue, comment, modify, or even has an objection don't hesitate to post it as a comment.

        ReplyDelete