Archive for the ‘Java’ Category

This is my FPS camera class for my application in computer graphics lecture. Oh yeah, i’m using Java and OpenGL (jOGL)

Camera object is used to store coordinate information and direction of viewing. Object camera has three normal vectors as a constituent component of direction-vector, up-vector, and right-vector. This third vector perpendicular to each other.

In order for viewing camera seemed to move around, over or away from terrain object is using rotation and translation of three vectors cameras mentioned above.

There are six process of camera rotation and translation as follows:

(more…)

JCIFS Example Functions

Posted: June 25, 2009 in Java, Programming
Tags:

jcifs

JCIFS is an Open Source client library that implements the CIFS/SMB networking protocol in 100% Java. CIFS is the standard file sharing protocol on the Microsoft Windows platform (e.g. Map Network Drive …). This client is used extensively in production on large Intranets.

Source :
http://jcifs.samba.org/
(more…)

In cryptography, MD5 (Message-Digest algorithm 5) is a widely used cryptographic hash function with a 128-bit hash value. As an Internet standard (RFC 1321), MD5 has been employed in a wide variety of security applications, and is also commonly used to check the integrity of files. However, it has been shown that MD5 is not collision resistant; as such, MD5 is not suitable for applications like SSL certificates or digital signatures that rely on this property. An MD5 hash is typically expressed as a 32 digit hexadecimal number.

package md5;

import java.security.MessageDigest;

public class Main
{
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception
{
String passwd = “azer89”;

MessageDigest m = MessageDigest.getInstance(“MD5”);
m.update(passwd.getBytes(“UTF8”));
byte s[] = m.digest();
String result = “”;
for (int i = 0; i < s.length; i++) { result += Integer.toHexString((0x000000ff & s[i]) | 0xffffff00).substring(6); } System.out.println(result); } } [/sourcecode] Source : http://en.wikipedia.org/wiki/MD5

Simple Socket Program Using Java

Posted: April 22, 2009 in Java, Programming
Tags: ,

In this program, i’m using Netbeans 6.5 IDE

The client program presents a simple user interface and prompts for text input. When you click the “Send Message” button, the text is sent to the server program. The client program expects an echo from the server and prints the echo it receives on its standard output.

The server program presents a simple user interface, and when you click the “Receive Message” button, the text received from the client is displayed.

Here’s the project files :

project

(more…)

Title : Data Structures & Algorithms in Java
Author: Mitchell Waite
Date: 1998
Language: English
Publisher: Sams
Size : 3124 KB

DOWNLOAD HERE !!!

Simple Thread di Java (2)

Posted: January 26, 2009 in Java, Programming
Tags: ,

Nah, berikut ini contoh penggunaan thread lainnya :

(more…)

Simple Thread di Java (1)

Posted: January 25, 2009 in Java, Programming
Tags: ,

Thread dalam ilmu komputer adalah singkatan dari “thread of execution”, didefinisikan sebagai sekumpulan instruksi yang dapat dieksekusi secara paralel dengan thread lainnya, dengan menggunakan metode time slice (ketika satu prosesor melakukan perpindahan antara satu thread ke thread lainnya) atau multiprocess (ketika thread-thread tersebut dieksekusi oleh prosesor yang berbeda dalam satu sistem). Thread sebenarnya mirip dengan proses, tapi cara berbagi sumber daya antara proses dengan thread adalah sangat berbeda. Multiplethread dapat dieksekusi secara pararel pada sistem komputer. Secara umum multithreading melakukan time-slicing (sama dengan time-division multipleks), dimana sebuah prosesor bekerja pada thread yang berbeda, dimana suatu kasus ditangani tidak sepenuhnya secara simultan, untuk prosesor singel pada dasarnya benar-benar melakukan sebuah pekerjaan pada satu waktu. Teknik switching ini memungkinkan prosesor seolah-olah bekerja secara simultan.
(wikipedia)

(more…)

Sebenarnya kedua paket ini sangat gampang untuk diinstall lewat repositori, caranya :
sudo apt-get install sun-java6-bin
sudo apt-get install netbeans

Nah, yang saya akan bahas disini adalah menginstall kedua paket tersebut secara manual, tidak lewat repositori.

(more…)

(Java GUI) Splash Screen

Posted: August 1, 2008 in Java, Programming
Tags: ,

Jframe memiki kemungkinan untuk dijadikan sebuah splash screen, tapi, sebaiknya kita menggunakan JWindow. Komponen ini didesain untuk membuat window tanpa title bar, sama seperti splash screen.
Untuk membuat splash scree, ada tiga langkah. Pertama, kita harus menampilkan sesuatu di splash screen tersebut, bisa saja teks ataupun gambar. kedua, kita set posisi dari splash screen tepat di tengah layar. Langkah terakhir, kita set berapa lama splash screen ditampilkan.


//SPLASH SCREEN

package musicplayerv2;

import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JWindow;
import javax.swing.JLabel;
import javax.swing.ImageIcon;

public class Splash extends JWindow
{
    public Splash(int timeOut)
    {
        add(new JLabel(new ImageIcon("images/nineTail.jpg")));  // Menambahkan label gambar

        pack();

        Dimension dim=Toolkit.getDefaultToolkit().getScreenSize();  // Mendapatkan ukuran layar

        int x=(dim.width-getSize().width)/2;  // Mendapatkan posisi tengah
        int y=(dim.height-getSize().height)/2;

        setLocation(x, y);  // Menetapkan lokasi window
        setVisible(true);  // Tampilkan window

        try
        {
            Thread.sleep(timeOut);  // Menunggu hingga waktu yang telah ditetapkan
        }
        catch (InterruptedException ex)
        {
            System.err.println(ex.getMessage());
        }
        dispose();  // Tutup dan bersihkan resource window
    }

}

(Java) Tower of Hanoi

Posted: July 31, 2008 in Java, Programming
Tags: ,

He he he..now, i make Tower of Hanoi in Java Language, if you want more explanation about what is Tower of Hanoi, click HERE.

import java.util.Scanner;

public class Main 
{
         
    public static void main(String[] args)
    {
        Scanner S=new Scanner(System.in);
        int x;
        char from='A', to='B', help='C';

        do{
            try
            {
                System.out.println("  input number of disk: ");
                x = Integer.parseInt(S.nextLine());
            }
            catch (NumberFormatException e)
            {
                x = -10;
            }
        }while(x==-10 || x>10);
        
        System.out.println("n  from = A, to = B, help = Cn");
        hanoi(x, from, to, help);
    }

    static void hanoi(int x, char from, char to, char help)
    {
        if (x > 0)
        {
            hanoi(x - 1, from, help, to);
            move(x, from, to);
            hanoi(x - 1, help, to, from);
        }

    }

    static void move(int x, char from, char to)
    {
        System.out.println("  move disk "+x+" from "+from+" to "+to);
    }

}