Archive

Posts Tagged ‘java’

Hello World! in Assembly, C, C++, Java, LISP, Pascal, VHDL

April 6, 2009 wonggoblog 1 comment

Wew, Hello World! in many programming languages.

Assembly

MIPS Assembly- RISC Processor

       .data
msg:     .asciiz "Hello, world!"
         .align 2
         .text
         .globl main
main:
         la $a0,msg
         li $v0,4
         syscall
         jr $ra

Intel x86,DOS, TASM

MODEL SMALL
IDEAL
STACK 100H

DATASEG
MSG DB 'Hello, World!', 13, '$'

CODESEG
Start:
MOV AX, @data
MOV DS, AX
MOV DX, OFFSET MSG
MOV AH, 09H ; output ascii string
INT 21H
MOV AX, 4C00H
INT 21H
END Start

C

#include <stdio.h>
int main(void){
	printf("Hello, world!\n");
	return 0;
}

C++

#include <iostream>

int main(){
	std::cout << "Hello, World!\n";
}

Java

public class HelloWorld
   {
        public static void main(String[] args)
        {
             System.out.println("Hello, world!");
        }
   }

LISP

(format t "Hello World!~%")
(write-line "Hello World!")
 "Hello World!"

VHDL

use std.textio.all;

ENTITY hello IS
END ENTITY hello;

ARCHITECTURE Scriptol OF hello IS
 CONSTANT message : string := "hello world";
BEGIN
 PROCESS
 variable L: line;
 BEGIN
 write(L, message);
 writeline(output, L);
 wait;
 END PROCESS;
END ARCHITECTURE Scriptol;

source: http://www.mycplus.com/featured-articles/hello-world-programs-in-300-programming-languages/

Starting Java Programming

February 26, 2009 wonggoblog Leave a comment

Java is an object oriented programming language.  It’s developed by James Gosling at Sun Microsystem in 1995. Java is a language derived from C++, so its instruction is similar to C++. Java sourcecode is compiled to bytecode (.class file). This bytecode can run in any computer architecture, as it’s slogan, “write once run anywhere” .

What to do?

1. Install JDK (Java Development Kit)

Download JDK at http://java.sun.com/javase/downloads/index.jsp. After downloading, install it by double clicking its installer. After it is installed, copy its bin address to Environtment of your computer. Right click My Computer -> Properties -> Advanced -> Environtment variable, look for the variable path , edit it, add the directories of your java.exe file (in bin folder) to it.

Now you can write javac and java to your command prompt  windows.

2. Start Programming

Open your text editor, I usually used notepad++, because it support many languages. If you use notepad++, change the language into Java. Try to write down this things..

public class HelloWorld{
                  public static void main(String[] args){
                                System.out.println(“Hello world….”);
                  }
}

Save this as HelloWorld.java

3. Compile it

Open command prompt. Change the directory to the directory you save HelloWorld.java.

>javac   HelloWorld.java

If you want to compile from other directory

>javac   (directory)/HelloWorld.java

After compiling, a .class file will be made. This .class file can run in any platform with JVM (Java Virtual Machine). JVM automatically installed when you install JDK.

4. Run your program

Write in your command prompt

>java   HelloWorld

Write the file name without the extension.. Then… you’ll see your text..

OK, that’s enough for today….

Categories: programming Tags: , ,

Robocode: Build The Best, Destroy The Rest

February 24, 2009 wonggoblog Leave a comment

robocode23

 

Robocode adalah sebuah game yang juga mengharuskan penggunanya untuk melakukan coding program. Bahasa pemrograman yang digunakan adalah Java TM, sehingga game ini bisa memperkenalkan bahkan melatih penggunanya dalam belajar bahasa Java dengan cara yang menyenangkan. Game ini berupa perang robot tank. Yang harus dilakukan pertama adalah membuat robot baru. Robot kita akan diberi perilaku standar, kita dapat mengganti sikap robot kita dalam menanggapi berbagai keadaan dengan melakukan coding. Misalnya kitaingin robot kita mendekati musuhnya ketika musuh terlihat. Robot buatan kita akan dipertandingkan dengan robot-robot lain. Robot yang dapat bertahan hingga akhir adalah pemenangnya.

Read more…

Categories: programming Tags: ,