Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Thursday, February 19, 2009

Sample Project I

Not only because some colleagues advised me to do, but also because i found it a good idea to publish a sample project of each year and/or semester ..

I'll start by this one "Sorting simulator" was done in the second year with my partner Moustafa.

Why I'm starting with that project especially? Because it had many uniqueness properties not in many other projects.

  • It 's UI is inspired from Microsoft office 2007 ribbon.
  • It's UI is developed in SWT library and the program in Java.
  • We used the Hexapixel project.
  • We used the Nebula project (The pshelf on the left).
  • Time of working in this project was directly before the final exams by 2:3 weeks, we felt that we either won't finish the project or it would affect our exams badly, but thank God all are finished and all are over.
Project size:
  • Src directory contains 9 packages.
  • Model package contains 12 classes.
  • UI main class contains 1322 lines.

Notes about the project
  • Worth mentioning that the program can simulate as long list as the screen resolution permits it to do.
  • All actual sorting algorithms are actually finished normally without being disturbed by UI rendering instructinos. How do we simulate then? After each swap of a pair of elements, a new node is pushed to the simulation queue of this sorting type, which (the queue) is popped purely asynchronously by another thread.
  • Why we did that? To make the running time of the sorting algorithm accurate and not affected by simulation.
The source is available to anyone, just send me an email or comment demanding it.

Finally Here are you some screen-shots due to the bad quality video

  • The options panel:
  • The Results panel:

  • The input panel (ribbon oriented):
  • An overall running instance:

Update The project is now opensource.

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..