Upgrade to Ubuntu Server 8.10

8 December 2008

In my previous post, was showing how to upgrade to Ubuntu Server 7.10.

Now I am writing a new post on how to upgrade to Ubuntu Server 8.10. The steps are very similar, however there's a slight changes in upgrading to 8.10.

I notice, when I was trying to upgrading from 7.10 to 8.10, I cannot go directly to 8.10. I have to

  • Upgrade from 7.10 to 8.04 then
  • Upgrade from 8.04 to 8.10

From 7.10 to 8.40, I just have to do the same steps as described in my previous post.

Now upgarding from 8.04 to 8.10, I have to do the following

Update Repository database

  1. sudo aptitude update
  2. sudo aptitude upgrade
  3. sudo aptitude dist-upgrade

Upgrade

  1. Run: sudo aptitude install update-manager-core
  2. Edit file /etc/update-manager/release-upgrades and set
    Prompt=normal
  3. Run: sudo do-release-upgrade
  4. Follow the instructions on-screen

Author: Manet Yim FAQ & Tip

A good practice to Compare String in Java

7 December 2008

Many people confused or don't understand the concept to use String object properly.
In most case, when they try to compare 2 identical string objects they don't get matching result.

When you have to do string comparison, there are few points to remember:

  • These operators <, <=, >, or >= cannot be used
  • These operator == and != don't compare character in the string or string outside String pool. Only use these operator when you want to check if String value is NULL
  • Use String .equals , String .compareTo and Collator .compare to get accurate comparison result. Use these operators when String value is not NULL

The following class demonstrate how string are being compare in different way and the result of each

import java.text.Collator;
 
public class TestCompareObject {
 
  public static void main(String[] args) {
      String s1 = "Same String Value but could be different result";
      String s2 = "Same String Value but could be different result";
      String s3 = new String ("Same String Value but could be different result");
      Collator c = Collator.getInstance();
 
      System.out.println("1. s1 == s2 ? : " + (s1 == s2 ? "true" : "false"));
      System.out.println("2. s1 == s3 ? : " + (s1 == s3 ? "true" : "false"));
      System.out.println("2. s1.compareTo(s3) : " +
              (s1.compareTo(s3) == 0 ? "equal" : "not equal"));
      System.out.println("3. s1.equals(s3) : " +
              (s1.equals(s3) ? "true" : "false"));
 
      int c_compare = c.compare(s1, s3);
      System.out.println("4. Collator compare(s1, s3) ? : " +
              (c_compare == 0 ? "equal" : "not equal") );
  }
 
}

Below is the output of this program

1. s1 == s2 ? : true
2. s1 == s3 ? : false
2. s1.compareTo(s3) : equal
3. s1.equals(s3) : true
4. Collator compare(s1, s3) ? : equal

Author: Manet Yim Programming

How to Read Text File in Java?

6 December 2008

Example below showing how to read text file

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
 
/**
 * Example class for Reading text file
 *
 * @author Manet Yim (manet.yim at gmail dot com)
 */
public class ReadTextFile {
 
    public void readTextFile() {
 
        // Create new file object
        File file = new File("C:\Temp\TestFolder\TestFile.txt");
 
        try {
            // create file reader instance
            FileReader fr = new FileReader(file);
            // create memory buffer to store data read from file
            BufferedReader br = new BufferedReader(fr);
            // variable to store text from file
            String line = "";
            while ( (line = br.readLine()) != null ){
                System.out.println(line);
            }
            // close file reader
            fr.close();
            // close buffer reader
            br.close();
 
        }
        // it is required to catch exception in case file is not found
        catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        // it is required to catch exception in case file cannot be read
        catch (IOException e) {
            e.printStackTrace();
        }
    }
 
    public static void main(String[] args) {
        ReadFile app = new ReadFile();
        app.readTextFile();
    }
 
}

Author: Manet Yim Programming

How to boot from CD-ROM for Dell Inspiron 600m?

26 November 2008

If you ever need to boot your Dell Inspiron 600m from CD-ROM, follow steps below

(Note that, this procedure might or might not work on the other model)

  • Insert Operation System CD
  • Shutdown the Computer
  • Restart Computer
  • Press F12 immediately after the DELLTM appears
  • Press the arrow key to select CD-ROM, and press Enter
  • When you see message "Press any key to boot from CD", press any key
  • PC is now booting from CD-ROM...

you can now continue with your setup

Author: Manet Yim FAQ & Tip

How to install 7-zip in Ubuntu?

15 November 2008

The traditional 7-zip only works in Windows 98/ME/NT/2000/XP/Vista. Now there is a port of the command line version to Linux/Unix call p7zip.

Here's how to install it in Ubuntu. It's fairly easy

First you probably need to updated your repositories list (optional) with the following command

sudo apt-get update

Now install p7zip with the following command

sudo apt-get install p7zip-full

Author: Manet Yim FAQ & Tip, Software

How to redirect page in HTML?

13 November 2008

Code below will demonstrate how to redirect from current page to a new page

<html>
<head>
<title></title>
<meta http-equiv="REFRESH" content="0;url=http://www.computer-faqs.com">
</head>
<body>
</body>
</html>

For demonstration, save this code in file.html then open it in a web browser, it will redirect the current page to the url specified in the meta tag.

Author: Manet Yim FAQ & Tip, Programming

What are Primitive Data Types in Java Language?

8 September 2008

This is the question that might rise by the Java programming beginner. Well, the answer to this question is: Primitive Data Types are the type that is preliminary defined by the Language which normally known as Keywords or reserved words.

In Java Language there are 8 primitive data types supported.

  • byte: is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive).
    Default value: 0
  • short: is a 16-bit signed two's complement integer. It has a minimum value of -32,768 and a maximum value of 32,767 (inclusive).
    Default value: 0
  • int: is a 32-bit signed two's complement integer. It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive).
    Default value: 0
  • long: is a 64-bit signed two's complement integer. It has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (inclusive).
    Default value: 0L
  • float: is a single-precision 32-bit IEEE 754 floating point. The value range can be found here.
    Default value: 0.0f
  • double: The double data type is a double-precision 64-bit IEEE 754 floating point. The value range can be found here.
    Default value: 0.0d
  • boolean: has only two possible values: true and false.
    Default value: false
  • char: is a single 16-bit Unicode character. It has a minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or 65,535 inclusive).
    Default value: '\u0000'

Number and String are not primitive data type. They are java Object defined under java.lang. They come with subclass or methods for manipulating the value of the object itself.

Reference:

Author: Manet Yim Programming

How to write One Line if-else statment in Java?

6 September 2008

Do you want to shorten your code? Below is a trick how to write one single line if-else statement.

Syntax

(condition) ? true-result : false-result

Where

  • condition: is your if condition
  • true-result: is executed when condition is true
  • false-result: is executed when condition is false

Example

System.out.println((1 + 2 == 4) ? "true" : "false");

This line of code will print "false" because the condition 1+2 not equals to 4

System.out.println((2 + 2 == 4) ? dothis() : dothat());

This line of code will dothis() method because the condition 2+2 equals to 4

Author: Manet Yim Programming

How to edit MP3 tags

5 September 2008

When you play music from an mp3 file, sometime you've seen the information displaying in the player which is not the same as it appears in the file name. It might be showing as "untitled" or any other name in the player such as Windows Media Player, iTune, Winamp, Real Player, etc.

Such player mentioned are reading information from the tag embeded within the mp3 file. These information are written by the producer. However you can change them, correct them or name them into some thing else you preferred or even in your own language!

There are many tools available or you can even user the built-in function in your default media player such as Windows Media Player, iTune, Winamp. But those functions might not be very flexible and very limited. I personally preferred a separate tool for my music tag management "Mp3tag". I find it the best tool I've ever encountered sofar. It's free, simple, light and feature rich.. hey hey and.. no ads, no spy-ware or the likes!

Follow this article, I will walk you through and show you how it is doneMp3tag Main Screen

Requirement

  • Software tool Mp3tag
  • One mp3 file

Steps

  • Download Mp3tag
  • Install it in your computer
    when you install, make sure you tick to enable "Context menu" in windows explorer
  • When done, right click on your mp3 file and select "Mp3tag" from the context menu
  • Main windows will appear similar to this screenshot below.
    Mp3tag Main
  • The screen above, showing the mp3 file with an empty tag information.
  • Now go a head and fill in the information you preferred
    Tips:
    * Make sure you select file from the right panel before you start punching in the data
    * You can add image to your mp3 file as well, e.g. the artist picture
    * You can drag picture and drop in the picture box
  • Below is another screenshot with filled tag information
  • Now Click on Save button straight away (good practice)

Output

Now you can play your MP3 file with your favorite media player. Here, I play it with Window Media Player

Done!

Last but not least, you can use Mp3tag with other file format as well. It supports the following formats

  • Advanced Audio Coding (aac)
  • Free Lossless Audio Codec (flac)
  • Monkey's Audio (ape)
  • Mpeg Layer 3 (mp3)
  • MPEG-4 (mp4 / m4a / m4b / iTunes compatible)
  • Musepack (mpc)
  • Ogg Vorbis (ogg)
  • OptimFROG (ofr)
  • OptimFROG DualStream (ofs)
  • Speex (spx)
  • Tom's Audio Kompressor (tak)
  • True Audio (tta)
  • Windows Media Audio (wma)
  • WavPack (wv)

Happy tagging :)

Site and References

  • Artist picture used in this article was taken from Wikipedia.org (http://en.wikipedia.org/wiki/Sinn_Sisamouth)

Author: Manet Yim FAQ & Tip, Software

Read and Write Properties file in Java

3 September 2008

Today, I wrote a simple class for reading properties file in Java Language. You could just use it without any need of further modification for a simple job like read and write value from and to properties file.

At the bottom of this class, there's a main method for you to test-run to see the effect of the result.

    /**
     * Example starting method, demonstrate how PropertiesIO class is used
     * @param args
     */
    public static void main(String[] args){
        PropertiesIO pio = new PropertiesIO("info.properties");
        System.out.println(pio.readValue("variableone"));
        System.out.println(pio.readValue("variabletwo"));
        pio.writeProperty("newkey", "This is value of newkey");
    }

Read more...

Author: Manet Yim Programming