Thursday, December 31, 2009

Merry Christmas and a Happy New Year!!!

Merry Christmas and a Happy New Year!!!

Thursday, December 24, 2009

Holiday Greetings

Merry Christmas to Everyone! :)

Saturday, December 19, 2009

Free Kubuntu 9.10 Book

When I learned about the principles of open source and what it stands for, I try to live by it and accept this wonderful virtue in life. Others may not share my beliefs but I give my best for them to understand by example. Since it is Christmas, here is my gift to you:

http://www.esnips.com/web/KubuntuBook

You can download it by clicking on the Title (not the buy now button), and click the Download link. You may also buy it as a donation if you want. You may also want to download the Table Of Contents separately.

Thanks, and Merry Christmas!

Saturday, December 12, 2009

Create Your Own Christmas Cards Using Gimp

This Christmas will be different, and to be different, why not create your own Christmas cards. Your friends will be reminded your friendship with them, and maybe give you a visit or even a party (or maybe, another card!). Check out this link; it will teach you how to make your own personalized cards:

http://www.linuxplanet.com/linuxplanet/tutorials/6925/1/

Thursday, December 10, 2009

Python Programming For Beginners

Some time ago, I've developed a photo slideshow using Python (that was early this year). What I like about it, is the syntax used that requires lesser typing, and how orderly your code will look like (since it will require you to indent uniformly). You could also test your code before you write code (using python's interactive command line). For beginners, I like you to check this webpage and see for yourself.


http://www.themaemo.com/python-for-newbies/#How%20Python%20works

Wednesday, December 2, 2009

CD, DVD Burning Made Simple

When I was still using XP, I use Nero for burning CDs, it's simple and it's free since it came with my CD-ROM drive. When I upgraded to Vista, unfortunately, it 's incompatible and won't run. When I tried Ubuntu, it came with Brasero, the CD, DVD burning software that is so easy to use and the best thing is it's free.

http://www.ghacks.net/2009/11/29/simple-linux-disk-burning-with-brasero/

Tuesday, December 1, 2009

Jobs For The Jobless

While waiting for employers to call you, why not help others improve KDE. KDE is the desktop manager for Linux and it is used among popular distributions like Kubuntu, OpenSuse, Mandriva, etc.

http://www.kdenews.org/2009/11/29/kde-community-forums-announce-continuation-klassroom

Friday, November 27, 2009

Making Most Out of Ubuntu 9.10

You've seen other tutorials after installing Ubuntu 9.10 on your computer. Well, here's another free, useful guide to get the most out of Ubuntu.

http://www.johannes-eva.net/index.php?page=2009_10_useful_ubuntu_guide_karmic

Thursday, November 26, 2009

Thank You!

I don't have much, but because God created freedom, I enjoy things that some tend to take for granted. There are those who still believe and that what gives us faith.

http://www.raiden.net/articles/giving_thanks_for_foss/

Tuesday, November 24, 2009

Create Database Using Openoffice.org Base Easily

As developers, we often create database using .NET or MySQL with the usual Add, Edit, Delete, Search, Print, Export to PDF, etc. We can do this with Entry Forms using OpenOffice.org Base:

http://www.linux.com/news/software/applications/176612-create-a-database-and-data-entry-form-in-openoffice-base

Saturday, November 21, 2009

Ubuntu Administration Tips

Linux is different from Windows that every files in Linux has permissions. For example, when you need to open a document, you must have permissions to open it, or modify it. You must also be the owner or belongs to a group to modify the file. In this tutorial, you will learn how to add, modify and delete users and groups, in such that every file in your system will know who is the owner, or which belongs to the group.

http://www.ubuntugeek.com/addmodify-and-delete-users-and-groups-in-ubuntu-using-gui.html

Ubuntu Linux 3 Years Ago

When I had a first glimpse of Ubuntu, I said to myself, why not give it a try. You can run Ubuntu on a live CD without installing it to your drive. My first impression is that it looks nice and it's easier to navigate on the applications installed since it is categorized on the menu. After that, I took the plunge and installed it. Back then, there were tons of bugs that I try to fix it myself. As you can see, when I written my first Ubuntu blog, there were “hacks” to fix the problems in programs. But after 3 years now, bugs were fixed and I can do more with Linux as I'm writing this today.


http://blogs.computerworld.com/15104/the_old_vs_the_new_linux_desktop

Thursday, November 19, 2009

Ubuntu App Store

Ubuntu has an App Store called Software Center like that you see on your Iphone. Using this application, you can see programs you installed and other programs you like using a simple interface. Here, you can add or remove programs instantly easily.
Or, there are alternatives that functions the same, having a web-based approach. You just select the apps you like then install it with one-click. Haven't tried this yet but I've seen this from other sites and works pretty well.

http://tuxsoftware.com/?p=122

Really Nice Indeed!

As I've said before, Kubuntu is for those who wanted a different looking desktop other than the Ubuntu default Gnome, which looks almost like running Windows. I've tried it and it's really looks very attractive especially when Desktop effects are enabled: translucent taskbar, nice icons, opacity of every applications, etc. (Well, you can also have some of this features in Ubuntu Gnome using compiz), but overall, it's really nice indeed.
http://www.dedoimedo.com/computers/kubuntu-9-10.html

Wednesday, November 18, 2009

Ubuntu 9.10: The Windows 7, Mac OSX Alternative

If you are a new user, download the default Gnome version in ubuntu website: www.ubuntulinux.org
If you like a different looking desktop, which is similar to the Windows interface, download Kubuntu: http://kubuntu.org
If you have a netbook, download the Ubuntu Netbook Remix version in ubuntu website: http://ubuntulinux.org
If you have a slow computer like a Pentium II, download and install Xubuntu: http://xubuntu.org
If you are an artist, download Ubuntu Studio: http://ubuntustudio.org
If you are a student or you like to use it in schools for children, download Edubuntu:
http://edubuntu.org
If you like to use it to your business, download Ubuntu Server Edition in ubuntu website: http://ubuntulinux.org

Of course, you may install these different flavors on your default ubuntu install: System->Administration->Synaptic, search ubuntu-desktop (for Gnome), kubuntu-desktop (for KDE), xubuntu (for XFCE), edubuntu (For Education Ubuntu).

Read the review here: http://www.linuxinsider.com/rsstory/68639.html?wlc=1258191912&wlc=1258537549

Monday, November 16, 2009

Linux for Netbooks

Netbooks are now the latest fad in computing industry. They are small and light, mobile enough to bring it anywhere. You can surf the web, do twitting, social networking, and write blogs wherever you are, and be free.
http://blogs.zdnet.com/BTL/?p=27383

Netbooks are not just that fast like the notebook counterparts that is why of its low-cost. Because of this, Linux is a better candidate since it would run faster in slower processors that it would even run on Pentium II machines.
http://blogs.computerworld.com/15090/lenovo_returns_to_the_linux_desktop

Mount UDF (Live File System) Volume CD, DVD In Ubuntu 9.04

1.sudo mount -t udf -o loop /dev/cdrom /media/cdrom.
2.That's it!
Note: This is read-only; you cannot write to the CD or DVD.

Saturday, November 14, 2009

Autostart Linux Commands In Kubuntu 9.10, KDE 4

1.Click Add Program and add command for example: sudo mount -t vboxsf music Shared_Music.
2.Click Properties, put a name, then Advanced Options.
3.Check Run In Terminal. Run as a Different User (if you're using a standard account), and choose the Administrator Username (This can be ommited using Opensuse 11.2).
4.That's it!

Ten Years of Desktop Linux

Actually, it's 3 years of desktop Linux for me, and really enjoyed it.

http://www.computerworld.com/s/article/9140169/Opinion_Linux_desktop_turns_10_world_yawns?taxonomyId=89&pageNumber=1

Friday, November 13, 2009

Removing Bouncing Cursor In Kubuntu 9.10 KDE 4

1.System Settings->Desktop->Launch Feedback->Busy Cursor.
2.Choose No Busy Cursor. That's it!

Wednesday, November 11, 2009

Installing Software In Ubuntu 9.10

Ubuntu 9.10 has a new way of installing software after the Ubuntu 9.04 release. I think it's much easier, and works great!
http://spiceminesofkessel.com/2009/11/11/a-beginners-guide-to-installing-software-in-ubuntu-9-10/

Installing Ubuntu Studio 9.10

Ubuntu Studio 9.10 http://ubuntustudio.org/
http://www.howtoforge.com/the-perfect-desktop-ubuntu-studio-9.10

With this link, you will learn how to install Ubuntu Studio 9.10 step by step.

Graphics:

* The GIMP - free software replacement for Adobe Photoshop
* F-Spot - full-featured personal photo management application for the GNOME desktop
* Google Picasa - application for organizing and editing digital photos

Internet:

* Firefox
* Opera
* Flash Player 10
* FileZilla - multithreaded FTP client
* Thunderbird - email and news client
* Evolution - combines e-mail, calendar, address book, and task list management functions
* aMule - P2P file sharing application
* Transmission BitTorrent Client - Bittorrent client
* Azureus/Vuze - Java Bittorrent client
* Empathy IM Client - multi-platform instant messaging client
* Skype
* Google Earth
* Xchat IRC - IRC client

Office:

* OpenOffice Writer - replacement for Microsoft Word
* OpenOffice Calc - replacement for Microsoft Excel
* Adobe Reader
* GnuCash - double-entry book-keeping personal finance system, similar to Quicken
* Scribus - open source desktop publishing (DTP) application

Sound & Video:

* Amarok - audio player
* Audacity - free, open source, cross platform digital audio editor
* Banshee - audio player, can encode/decode various formats and synchronize music with Apple iPods
* MPlayer - media player (video/audio), supports WMA
* Rhythmbox Music Player - audio player, similar to Apple's iTunes, with support for iPods
* gtkPod - software similar to Apple's iTunes, supports iPod, iPod nano, iPod shuffle, iPod photo, and iPod mini
* XMMS - audio player similar to Winamp
* dvd::rip - full featured DVD copy program
* Kino - free digital video editor
* Sound Juicer CD Extractor - CD ripping tool, supports various audio codecs
* VLC Media Player - media player (video/audio)
* Helix Player - media player, similar to the Real Player
* Totem - media player (video/audio)
* Xine - media player, supports various formats; can play DVDs
* Brasero - CD/DVD burning program
* K3B - CD/DVD burning program
* Multimedia Codecs

Programming:

* KompoZer - WYSIWYG HTML editor, similar to Macromedia Dreamweaver, but not as feature-rich (yet)
* Bluefish - text editor, suitable for many programming and markup languages
* Quanta Plus - web development environment, including a WYSIWYG editor

Other:

* VirtualBox OSE- lets you run your old Windows desktop as a virtual machine under your Linux desktop, so you don't have to entirely abandon Windows
* TrueType fonts
* Java
* Read-/Write support for NTFS partitions

Lots of our desired applications are available in the Ubuntu repositories, and some of these applications have been contributed by the Ubuntu community.

These application list is provided by Falko Timme.

Another link for more applications: http://www.pcauthority.com.au/News/160222,5-more-free-linux-apps-you-cant-do-without.aspx

Monday, November 9, 2009

Ubuntu 9.10 vs. Windows 7

http://blogs.computerworld.com/15035/5_reasons_why_ubuntu_9_10_is_better_than_windows_7

I've been using Ubuntu for three years now, and I'm an Ubuntu user ever since. I'm not saying that Windows is bad it's just that it's quite expensive, living in a poor country, having prices with the exchange rate in pesos, for me it's better to save money than spend it on original software that costs around P3,000 each. In Ubuntu, you got everything you need: photo editing, video editing, audio recording, office, etc. You just have to have time to learn these applications, which I did, just like learning in Windows.
I've downloaded the Windows 7 release candidate, and it's nice, but it's actually the same as any other OS, it's just another different interface. What matters most is that you can do your work with lesser problems and earn some money.

Sunday, November 8, 2009

How To Install Ubuntu 9.10 To A USB Drive, Pen-drive, Thumb-drive

Follow the instructions on this link:
http://news.softpedia.com/news/Installing-Ubuntu-9-10-126370.shtml

Few reminders:
1.In Hard Disk Partitioning, be sure to choose the USB Drive and not your hard disk. This is usually labeled what your brand of pen-drive you have.
2.In “Are you really ready for Ubuntu?” the final step, also be sure to choose your pen-drive not your hard disk or it will overwrite your existing boot loader.
3.That's it!

Where Is The Total Market Share of Ubuntu?

Steve Ballmer himself told everyone that Windows 7 is doing "fanatastic," and has overtaken Vista on sales over a similar period. Meanwhile, Mac sales increased 17%, while Ubuntu doesn't have any numbers to compute.

http://www.pcworld.com/article/181599/windows_7_sales_up_but_is_it_really_a_hit.html

Thursday, November 5, 2009

OpenOffice.org Writer Tips and Tricks

I'm not a writer by profession, but I did books about stories, computer tutorials, and blogging. Usually, I do it alone, but if you're writing with others, this tips using OpenOffice.org Writer will help you collaborate with fellow authors.

http://www.linux.com/news/software/applications/43783-lesser-known-features-in-openofficeorg-writer

How To Upgrade Ubuntu 9.04 to 9.10 Using An Alternate CD

http://www.ubuntulinux.org/getubuntu/upgrading#Upgrading%20Using%20the%20Alternate%20CD/DVD

http://mirror.anl.gov/pub/ubuntu-iso/CDs/karmic/

Only one caveat: I never tried using this procedure, I always do network upgrades using the Update Manager because it's much simpler.

Tuesday, November 3, 2009

Convert MIDI Files To MP3, OGG, and etc.

Converting MIDI Files From Rosegarden To MP3,OGG, and etc.

1.In Rosegarden, export to MIDI file.
2.Then, Convert to OGG using Sound Converter.
3.That's it!

Monday, November 2, 2009

Which Is The Fastest?

Here we have Windows Vista; Windows 7;Ubuntu 9.04, and Ubuntu 9.10. Which OS boot the fastest? Check it out here:

http://tuxradar.com/content/vista-windows-7-ubuntu-904-and-910-boot-speed-comparison

Sunday, November 1, 2009

Save Money, Use Open Source

Using Linux can save you money, while getting your job done. It will also help you learn new things and get involved in the community, and be a part of Open Source.

http://news.cnet.com/8301-13505_3-10387512-16.html?part=rss&subj=news&tag=2547-1_3-0-20

Saturday, October 31, 2009

Ubuntu 9.10 vs. Snow Leopard vs. Windows 7

Now that new versions of the most popular Operating Systems are out, an upgrade war is imminent. Check it out here: http://blogs.computerworld.com/14990/upgrade_wars_snow_leopard_ubuntu_windows_7

Friday, October 30, 2009

UBUNTU 9.10 IS OUT NOW!!!

Hear ye, hear ye, Ubuntu 9.10 is out now. Grab your copy for FREE!

http://education.zdnet.com/?p=3303

Tuesday, October 27, 2009

Tuesday, October 20, 2009

Monday, October 19, 2009

Sunday, October 18, 2009

Friday, October 16, 2009

The Linux Foundation Video Site:: Challenges at the Office

The office has its challenges, so watch this!

The Linux Foundation Video Site:: Be Linux

Another Linux Video that proves that penguins can fly.

Robbert Bobbert and the Bubble Machine • We R Super Heroes

Check out this music video, "We Are Super Heroes" from Apples In Stereo!

Enjoy!

Wednesday, October 14, 2009

Check out this music video, "We Are Super Heroes" from Apples In Stereo: http://www.youtube.com/watch?v=4gabQNUch00

Enjoy!

Sunday, August 30, 2009

Java Basics Using Qt Jambi Tutorial

If you want to program in Java using Qt Jambi Framework from Nokia, this is it. Though this is just a tutorial of the basics, you will learn how to create your first Qt GUI program and run it. It also includes Java topics such as Language Basics: Strings, Numbers, Arrays, String Builder, Expressions, Statements, Blocks, and OOP concepts like Classes, Objects, and so on. It also include a link where you could copy and paste the source code book example creating your own Photo Slideshow!

Download PDF version here.

The Table of Contents is located here.

Please make a small donation; it is very much appreciated. :)

This is the updated version. August 2009.

Saturday, August 22, 2009

Nokia in Java Me: “Null Pointer Exception”

1.Check the resources, or m3G files, or re-import it in Eclipse Galileo

Sunday, August 9, 2009

Get Free Second Life Linden Dollars!

I'm a newbie at Second Life, and I've been exploring for days now. I went to the Dresden Art Gallery located on first landmark you visit, and I must say, I liked it very much, especially how realistic the paintings are. Just learned that they went through years to build it, truly amazing!

After your exploring, somehow, you will need to buy things. Even uploading images could cost something. Someone I chatted with someone recently and told me how I would earn money, called Lindens, eventually be successful in Second Life. Then, I came about MetaRL. It's a website where you can earn Linden dollars by playing their games, joining contest, or surveys, and most importantly, referrals. Here, you will earn meta points and convert it to Lindens for Second Life. You can learn more by visiting their website: www.metarl.com

Don't forget to add me in your referrals! http://www.metarl.com/register.php?referral=metarljhun

Thanks!

Saturday, August 8, 2009

Eclipse Galileo: Couldn't Run Jad, “manifest must have midlet-1”

1.Re-create the Project Midlet.
2.Create Java Me Midlet with package name.

Friday, August 7, 2009

Eclipse Galileo: “No Class Definition Found Error”

 
  1. Just separate the classes to another file.

Saturday, June 13, 2009

Java Basics Using Qt Jambi Tutorial

QT Jambi

Now that we have discussed the basics of the Java Language, we move on to using Qt Framework in our Java Programs.

We are going to use an example project that would explain on how Qt works.

The program will be a photo slideshow with these requirements:

  1. Import photos and show it.

  2. Import music.

  3. Play the slideshow.


Using Qt Designer

Qt designer is an interface that helps you design your application. Just like GUI designing in other IDE such as Visual Studio or Eclipse, Netbeans, etc.

When designing the GUI (Graphical User Interface), you can use the Qt Jambi Designer included in the Qt Jambi SDK or the Eclipse Qt Integration plugin. Since we are learning the fundamentals, it is better to use the Qt Designer that comes with Qt Jambi SDK, then convert the GUI you designed to Java code.


Since we already made our first application using the steps in “The Basics,” “Using Qt Designer,” we'll just tell you what to add in our photo slideshow.


  1. List Widget

  2. Text Label

  3. Horizontal Slider

  4. (3) Push buttons

  5. Menu with these:

File->Import Photos->Import Music->Exit


It is recommended to rename these “widgets” using the Object Inspector Located on the right side of the designer by clicking the tab below. This will aid you on your coding for it is easier to remember because it will show up in your produced Java code and avoid variable name clashes by making it unique.


I won't write the source code here since it is not efficient, instead go to this http://javaqt.blogspot.com/2008/11/java-using-qt-jambi-tutorial-example.html and copy it.


The program works as it should, but it has “bugs” (errors) in it as to teach you Java using Qt Framework. Read the comments the ones after the “//” or “/*” and “*/”.

In the program or code, there are lines of code which I used String Builder, but a fixed array should be used instead.

In debugging (fixing) the code, I would suggest that you print out the variables or objects to see if the values it contain is correct (although, you can also see the values of variables on some decent IDEs like Eclipse, etc.) like,

System.out.println(variable); throughout the program.

In Java development, I always encounter problems on using class variables, like in a GUI in Qt, therefore add the keyword “static” so it would have one copy of that variable to use (this is also called static fields).

It is recommended that you read APIs (Application Programming Interface) documentation (and I know you would) and study it on how to use it. Search on the Internet for these or go to: http://java.sun.com/docs/books/tutorial/index.html download it, and the documentation included on the Qt Jambi SDK.

When creating a program, always think on solving one problem at a time, it is good practice that you design your program first on paper, but of course in reality, this isn't so.

Always make sure that you test your programs thoroughly before giving it to your boss because results matter.

So, I leave you with an unfinished program so you could experiment on. Happy Programming!


Friday, June 12, 2009

Java Basics Using Qt Jambi Tutorial

Generics

Generics makes it easy to catch runtime bugs such as wrong argument types. It tells the compiler to inform an error when there are wrong types, when a method call passes a string when it is expecting an integer.

Ex.

public class Vehicle{

private Object object;

public void start(Object object){

this.object = object;

}

public Object speed(){

return object;

}

public static void main (String[] args){

Vehicle v1 = new Vehicle(); created by different programmer

vi.start(“100”);


Integer speedofv = (Integer)v1.speed();

System.out.println(“speed of car is “ + speedofv);

}

} created by another programmer


This will result an error because it passes string where it expects an integer (this is at runtime not compile time).


Example on how to use generics:

public class Vehicle{

private T t; //T stands for type

public void start(T t){

this.t = t;

}

public T speed(){

return t;

}

//we just replaced Object with T.

public static void main(String[] args){

Vehiclev1 = new Vehicle();

v1.start(“100”);

Integer speedofv = v1.speed(); //no explicit casting

System.out.println(speedofv);

This will result an error in compile time having wrong types.


Type Convention:

  1. T-type

  2. N-Number

  3. E-Element

  4. V-Value

  5. K-Key


You can also use generics in methods. The difference is it only accessed inside the method.


public<u>void direction(U u){

System.out.println(“T:” + t.getClass().getName());

System.out.println(“U:” + u.getClass().getName());

}


public static void main (String[] args){

Vehicle<integer>v1 = new Vehicle();

v1.start(100);

v1.speed();

v1.direction(“North”);

}

prints out: T: java.lang.Integer

U:java.lang.String

to be continued...

Thursday, June 11, 2009

Java Basics Using Qt Jambi Tutorial

Packages

Packages is used to group related types which are classes, interfaces, enumerations and annotation types.

Ex.

//in UseCar.java

package com.cars.engine;

public interface UseCar{}

//in Vehicle.java

package com.cars.engine;

public abstract class Vehicle{}



3 Ways to access members:

  1. Full qualified name. Ex. com.cars.engine.Vehicle;

  2. Import package member. Ex. Vehicle v1= new Vehicle();

  3. Import members entire package.

Ex.

import com.cars.engine.*;

Vehicle v1 = new Vehicle();

Car car1 = new Car();

Things you must remember with packages:

  1. You must name packages with correct convention to make it unique and avoid name clashes.

Ex. package com.cars.engine;

  1. Your class files should be located in the directories with names using the package name.

$javac -classpath /path/to/jar:/path/to/jar -d /path/to/folder/containing/java/files/ MyCar.java Vehicle.java

$jar cfm MyCar.jar Manifest.txt /com/cars/engine/*.class

$java -jar Main.jar

to be continued...

Tuesday, June 9, 2009

Java Basics Using Qt Jambi Tutorial

Interface

Since we cannot have multiple instances using a class, we can use interfaces. Interfaces can implement from other interfaces.

Ex.

public interface UseCar{

int start (boolean ismoving,boolean key);

int stop (boolean ismoving,boolean breaks);

}

public class BMWCar implements UseCar{ //is used to provide methods declared from the interface.

int start (boolean ismoving, boolean key){

}

}

//is used so it can be available to any package to any classes. If omitted, it can be accessed to classes with same package.


Note: It can also contain constant declarations.


You must remember these rules in using Interfaces:

  1. All the methods in interface should be declared on your source code.

  2. Use public if you want to access the interface to any classes in any package.


When using or to access the interface methods through class instantiation implementing the interface.

Ex.

InterfaceVehicle.java


import java.lang.*;


public class InterfaceVehicle implements UseCar{


public int whichVehicleRunsFaster(int v1, int v2){

if (v1 > v2){

return v1;

}

else{

return v2;

}

}

public static void main(String[] args){

int car1 = 100;

int car2 = 200;

int cars;

InterfaceVehicle vehicle = new InterfaceVehicle();

cars = vehicle.whichVehicleRunsFaster(car1,car2);

System.out.println(cars);

}

}

UseCar.java


import java.lang.*;


public interface UseCar{

public int whichVehicleRunsFaster(int vehicle1, int vehicle2);

}

Note: Classes that implements this interface “inherit” the constants and must implement methods.


If an abstract class contains only abstract method declarations, it should be interface.


to be continued...

Monday, June 8, 2009

Java Basics Using Qt Jambi Tutorial

Classes

We've already seen classes from previous examples like class Vehicle. In object-oriented programming (OOP), we always create the most common or generalized class.

Ex.

public class Vehicle{

}

We created the class as Vehicle and from that, we put methods that is common to all vehicles.

Ex.

public class Vehicle{

public void accelerate(){

}

public void decelerate(){

}

public void start(){

}

public void stop(){

}

public void turnDirection(){

}

}

Then we create a “sub-class” called “Car”:

public class Car extends Vehicle{

public void turnOnRadio(){

}

public void turnOnWiper(){

}

}

And, also inheriting from Vehicle class we create:

public class Bicycle extends Vehicle{

public void adjustMirror(){

}

public void soundRinger(){

}

}

The Car and Bicycle are called sub-classes and Vehicle is the super class. We call this “inheritance.”

Then we can access the super class methods in our code.

Ex.

public static void main(String[] args){

Car car1 = new Car();

car1.start(); //since we inherited the methods in super class Vehicle, we can call its methods.

car1.accelerate();

car1.turnOnRadio(); //we can also use Car's own methods.

car1.stop();

Note: We can also use Vehicle's properties such as variables, constructors by using the super keyword, and even the super class' overriding methods.

Ex.

public class Vehicle{

public void start(){

System.out.println(“Start your engines”);

}

}

public class Car extends Vehicle(){

public void start(){

super.start();

}

}

Example of executing constructors in super class:

public class Vehicle{

public Vehicle(){

}

}

public class Car extends Vehicle{

public Car(){

super();

}

}

It can also pass in arguments:

public Car(int wheels, int doors){

super(wheels,doors)

}

to be continued...

Sunday, June 7, 2009

Java Basics Using Qt Jambi Tutorial

Parameters and Arguments – Parameters are what we pass in variables in methods. We already seen this in previous examples:

Ex.

import java.lang.*;


public class VehicleMoving{

public static int gear;

public static int speed;

public VehicleMoving(int gear){

this.gear = gear;

}

public void accelerate(){

switch(gear){

case 1:

speed = 10;

System.out.println("the car is moving at " + speed);break;

case 2:

speed = 20;

System.out.println("the car is moving at " + speed);break;

}

}

public static void main(String[] args){

VehicleMoving car = new VehicleMoving(1);

car.accelerate();

VehicleMoving car2 = new VehicleMoving(2);

car.accelerate();

}

}


Vehicle constructor expects one argument which is (1) with the parameter gear. 1 is an integer, so it must have data types int vehicle (int gear).


Remember these Rules:

  1. The method call or class instance of constructors must have the same number of arguments or parameters.

  2. The arguments passed-in should have the same data type.

to be continued...

Saturday, June 6, 2009

Java Basics Using Qt Jambi Tutorial

Constructors

Constructors are used to initialize our variables but this is optional. As I've said, there is already a default constructor created for us.

Ex.

public class Vehicle{

public Vehicle(int wheels){

this.wheels = wheels;

}

}

There are rules in creating constructors:

  1. It should have the same name as your class.

  2. It does not have a return type.

  3. You can create as many constructors provided you must have different number of parameters or different type.

Ex.

public class Vehicle{

public Vehicle(int wheels){

}

public Vehicle(String color, int doors){

}

public Vehicle(int gears, int steeringwheels){

}

}

Note: It is recommended you use different name for your parameters from the class variables.

Ex.

public class Vehicle{

public int trunk;

public String type;

public Vehicle(int wheels, int gears){

trunk = 1;

type = “car”;

wheels = 4;

gears = 6;

}

}

If you have same variable names for your parameters and class variables use the keyword “this.”

Ex.

public class Vehicle{

public int wheels;

public int gears;

public Vehicle(int wheels, int gears){

this.wheels = wheels;

this.gears = gears;

}

}

to be continued...

Friday, June 5, 2009

Java Basics Using Qt Jambi Tutorial

Functions

Functions are also called methods. Functions are the verb or action for which your program will do.

Ex.

public class Vehicle{

plublic void accelerate(){

}

public void turnDirection(){

}

public static void main(String[] args){

Vehicle car = new Vehicle();

car.accelerate();

}

}


Here, we created the class Vehicle and inside the class are three functions: accelerate,turnDirection and the required main method.


In the main method, we created an instance of a class (can also be called “creating object”) Vehicle with the variable car. The “new” keyword creates the instance and executes the default constructor, then we call the method accelerate like car.accelerate(). This executes the code inside the function we defined accelerate. For our car to turn direction, we call the turnDirection method like this: car.turnDirection();

to be continued...

Thursday, June 4, 2009

Java Basics Using Qt Jambi Tutorial

  1. Branching Statements

    1. break; - The break statement terminates the loop.

    2. continue; - when reached, it goes to the loop statement and evaluates the condition.

Ex. for (x=0; x<10;x++){

if (x==4){

continue;

}

System.out.println(x);

}

//this code prints from 0 to 3 and skips 4 and prints 5 to 9.

    1. return;

Ex.

import java.lang.*;


public class AddNumbers{

public int add(int x,int y){

return x + y; //passes 1 and 2 then adds them and return the result

}

public static void main(String[] args){

boolean addnum = true;

AddNumbers num = new AddNumbers();

while (addnum){

System.out.println(num.add(1,2)); //passes 1 and 2 to add method and prints the result.

addnum = false;

}

}

}

to be continued...

Java Basics Using Qt Jambi Tutorial

  1. Looping Statements

    1. while, do-while statements – The while statement executes a block while the condition is true.

Ex.

import java.lang.*;


public class MovingCar{

static boolean ismoving = true;

static boolean breaks = false;


public static void main(String[] args){

while(ismoving){

if(breaks){

ismoving = false;

System.out.println("breaks is applied...stopped.");

}

else{

System.out.println("The car is moving.");

}

breaks = true;

}

}

}


This code prints “The car is moving.” once and breaks is applied and goes out of the while loop.


Do-while statements' difference is hat the condition is placed at the bottom and executes the block of code once.

Ex.

do{

//statements

}while (condition);


  1. For Loop

Ex. for (x=0; x<10;>

//increment or decrement (x--)using unary operator

//initialization and executes once.


//Condition when met, or when it evaluates to false, it terminates.

System.out.println(x);

}

to be continued...

Tuesday, June 2, 2009

Java Basics Using Qt Jambi Tutorial

Control Flow

Your code is usually executed from top to bottom. Control flow statements changes the flow of a program depending on a condition. There are 3 control flow statements.


  1. Decision-making statements

    1. if statement

Ex.

int wheels = 4; //declare and assign wheels to 4.

if (wheels == 4) {

System.out.println(“It is a car”); //executes this if wheel is 4.


}else if (wheels == 2){

System.out.println(“It is a bicycle”); //executes this if wheel is 2.

}else if (wheels == 1){

System.out.println(“It is a unicycle”);// executes this if wheel is 1.

}else{

System.out.println(“It is another vehicle”); //executes this if no other conditions are met.

}


Note: else if and else are optional.


In this example, we used the == equality operator rather than the assignment operator = to test for conditions.


    1. Switch Statements – Switch statement works with:

      1. Primitive data types

      2. Enumerated types

      3. Few classes like Integers, etc.

Ex.

int wheels = 4;

switch (wheels){

case 1: System.out.println(“unicycle”); break;

case 2: System.out.println(“bicycle”); break;

case 3: System.out.println(“tri-cycle”);break;

case 4: System.out.println(“car”);break;

default: System.out.println(“another vehicle”);

}


Example of Enumerated Types, Switch Statement

import java.lang.*;

public class enumVehicle{

enum Wheels{

ONE,TWO,FOUR //assign fixed set of constants.

}


Wheels wheels; //declare wheels variable having Wheels enum.

public enumVehicle(Wheels wheels){ //create constructor

this.wheels = wheels; //initializes variable

}

public void whatVehicle(){

switch(wheels){

case ONE: System.out.println("unicycle");break; //prints unicycle since we pass Wheels.ONE to constructor and assign it to wheels.

case TWO: System.out.println("bicycle");break;

case FOUR: System.out.println("car");break;

default: System.out.println("another vehicle");

}

}

public static void main(String[] args){

enumVehicle vehicle1 = new enumVehicle(Wheels.ONE); //execute constructor enumVehicle and assign Wheels.ONE to wheels.

vehicle1.whatVehicle(); //call whatVehicle method and print “unicycle.”

enumVehicle vehicle2 = new enumVehicle(Wheels.FOUR); //execute constructor enumVehicle and assign Wheels.FOUR to wheels.

vehicle2.whatVehicle(); //call whatVehicle method and print “car.”

}

}

to be continued...

Java Basics Using Qt Jambi Tutorial

Operators, Expressions, Statements and Blocks

  1. Operators – Operators are symbols that do something on operands.

Ex. 1 + 2

operator +

operands 1, 2

Operands can be variables with values in them.

int a = 1; //assign a to 1 called, which = is called assignment operators.

int b = 2; //assign b to 2

int c = a + b; //add a and b and give the result to c which is also type int.

System.out.println(c); //print result which is 3.


There are two kinds of operators:

    1. Equality and Relational


== equal to

!= not equal to

> greater than

>= greater than or equal to

<>

<= less than or equal to


    1. Conditional


&& Conditional-AND

|| Conditional-OR


  1. Expressions – Expressions are made up of variables, operators or method calls.

Ex. int a = 1; //data type of a is int.

int b = 2; //data type of b is also int.

int c = a + b; //data type of c must be int.


  1. Statements – Statements are logical lines which ends with a semi-colon.

Ex. int a = 1; //one statement

System.out.println(“Hello World!”); //one statement.


Note: A Statement always ends with a semi-colon.


  1. Blocks – Blocks are made up of statements within curly braces:

Ex.

public static void main(String[] args){

int a = 1;

int b = 2; This is a block.

int c = a + b;

System.out.println(c);

}

or,

if (condition){

System.out.println(“Condition is true.”); This is a block.

}

else{

System.out.println(“Condition is false.”); else block

}


to be continued...

Monday, June 1, 2009

Java Basics Using Qt Jambi Tutorial

Identifier Naming

You just have to remember these rules in naming identifiers or variables.

  1. Variable names are case-sensitive.

  2. Begins with a letter or underscore.

  3. Whitespace are not permitted.

  4. Subsequent characters can be letters, digits, dollar sign or underscore.

  5. Must not be a reserved word or keyword.


Good Naming Practices

  1. Use full words like: wheels, speed, etc.

  2. Do not use underscores as the first character.

  3. If using more than one word, capitalize the first letter of the second word.

Ex. currentSpeed, currentDirections, etc.

  1. When using constants, capitalize all letters and separate the next word by an underscore.

Ex. NUM_WHEELS;

to be continued...

Sunday, May 31, 2009

Java Basics Using Qt Jambi Tutorial

Variables

We've already used variables in our previous examples. Variables are identifiers that store values in your computer memory. There are four types of variables:

  1. Instance variables – variables with unique values.

Ex. int wheels=4;

  1. Class variables – variables with fixed value.

Ex. static in numSteeringWheel =1;

  1. Local variables – can only be accessed inside a method block when placed inside it.

Ex. public void accelerate(){

int currentSpeed =20;

}

  1. Parameters – variables inside method or constructors and exception handlers.

Ex. public static void main(String[] args) //args is the parameter with a String type of method main.

to be continued...

Saturday, May 30, 2009

Java Basics Using Qt Jambi Tutorial

String Builder Class

You can use this class to append or insert strings (just like concatenating strings, "String.concat()").


Ex.

String s =”hello”; //declare assign string “hello” to s.

StringBuilder sb=new StringBuilder(s); //creates an instance of class StringBuilder and puts the string s to sb StringBuilder.

sb.insert(4,”o”); //would insert the “n” inside the string “hello” and will be “helloo”.

sb.append(“world”); //will make “hello” string to “helloworld”.

Note: Append will always put the string at the end of the original string.

to be continued...

Friday, May 29, 2009

Java Basics Using Qt Jambi Tutorial

Numbers

Number class is used so you can utilize its methods for conversion or when an argument of a method expects an object.


Example of converting numeric values to numeric types using number class:

Number num=10; //create number data type

int numInt = num.intValue(); //convert Number to int data type

System.out.print(numInt);


Example of converting string to integer using integer class:

String s=”20”; //declare string variables to “20”

int numInt=Integer.parseInt(s); //converts string s to integer numInt

System.out.println(numInt); //print the int


Strings

From the previous example, we declared a string variable String s=”20”; The “20” Here is a string since it is enclosed by “”, which signifies it is a string not an integer or number and it is accompanied by the keyword String. We can also say String s=”hello there!”


Getting the Length of a String

Ex.

String s=”hello!”; //declare s as String and assign it to “hello!”

System.out.println(s.length()); //s.length since we assigned “hello!” to s, we access the String class method length to get the length of the string. System.out.println() prints the string.


Concatenating Strings or Joining Strings

Ex.

String s=”helloˍ̱̱̱“; //(“ˍ̱̱̱” is a space) declare s as string and assign s to “helloˍ̱̱̱

System.out.println(s.concat(“world!”)); //concatenates or joins the string from s (which is hello) to “world!”, then prints the joined string.


Another way is,

String s=”helloˍ̱̱̱“ + “world!” //by using + to join or concatenate strings.


String Formatting

Example:

double doubleVar = 10.5; //declare and assign double 10.5.

int intVar=20; //declare, assign intVar to 20.

String stringVar=”hello!”; //declare and assign string var to “hello”

String fs; //declare fs as String.

fs=String.format (“The value of double var is %f, while the value of the “ + “integer variable is %d, and string is “+ “%s', doubleVar,intVar,stringVar); //Use method format of String class %f to assign the variable doubleVar, %d to intVar, %s to stringVar. These %f,%d,%s are called format specifiers which replaces the value in sequence after the (“”,)


Ex.

int i =10; //declare and assign value 10 to I;

String s = String.valueOf(i); //converts I to String using valueOf().

Note: you can use valueOf when converting to byte,integer,double,float,long and short.


Ex.

String s =”20”; //declare and assign string “20” to s.

integer a = Integer.valueOf(s); //converts s(20) to Integer a.


Getting Parts of a String


Ex.

String s = “hello world!”; //assign “hello world” to s as string.

String ss = s.substring(5,10); //returns “world”


0 1 2 3 4 5 6 7 8 9 10

h e l l o w o r l d

Note: Just remember the 5 is inclusion, and 10 is exclusion.


Other Methods You Can Use:


indexOf() //returns the index number of the string or char specified.

charAt() //returns the character where the index is specified.

trim() //removes the leading and trailing spaces.

toLowerCase() //returns a copy of string to lowercase.

toUpperCase() //returns a copy of string to uppercase.

to be continued...