Geekpedia Tutorials Home

Building a C# Chat Client and Server

Building a C# Chat Client and ServerA step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.

in C# Programming Tutorials

Getting Hard Drive Information

Getting Hard Drive InformationA C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.

in C# Programming Tutorials

UPS Shipping Calculator

UPS Shipping CalculatorThis tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.

in PHP Programming Tutorials

Create Your Own Rich Text Editor

Create Your Own Rich Text EditorCreating a Rich Text Editor using JavaScript is easier to do than you might think, thanks to the support of modern browsers; this tutorial will walk you through it.

in JavaScript Programming Tutorials
Search
Tutorials
Programming Tutorials
IT Jobs
From CareerBuilder

Getting Started with Java

Start Programming with Java, first sample code and some additional details

On Tuesday, May 25th 2004 at 03:52 PM
By Sina Marandian Hagh (View Profile)
*****   (Rated 4.4 with 32 votes)
Contextual Ads
More Java Resources
Advertisement

In the first article I generally described the usages and abalities
of Java. Now we have better to start the real Java. The programmers of
C and C++ would find Java very friendly and familier, because it's similar
to C++ in syntax. On the other hand Java is a full object-oriented
programming language.

Everything in Java is an object, even a Java program. We suppose you
know the basic concepts of OOP and start Java.



Attention: C++ programmers should remember that there are some
differences between OOP in Java and OOp in C++.



To see how lovely and simple Java is, let's have our first program
just now:

(Sample1):



    class startingJava {
     
        public static void main {

             System.out.println("This is my first Java program.");

           }
       }



After installing JDK (Java Develepment Kit) do the following setting
on your Windows:

1. Go to the folder you have installed JDK and creat a new folder
in the root called "Programs".

2. Right-click on My Computer icon in your Windows Desktop.

3. Go to Properties/Advanced/Envierment Variables/

4. In the User variable,press New. Set the Variable Name to: "path"

5. Set the Variable Value to bin folder on the path you've installed
JDK.

( for example: C:\Java\bin\ )

6. Press OK.

7. In the System variable,press New. Set the Variable Name to:
"Class path".

8. Set the Variable value to the path of the folder you have
recently created.

( for example: C:\Java\Programs\ )

9. Press OK.


Note: You can download final version of JDK from following link:


https://jsecom16.sun.com/ECom/EComActionServlet/LegalPage:~:com.sun.
sunit.sdlc.content.LegalWebPageInfo;jsessionid=jsecom16.sun.com-
1386d%3A40b1909d%3A57cbd686844da024


********************************************************************


Running the first Program:


In order to compile your first Java program, type Sample1 code in a
simple text editor such as Windows Notpad.


Atention: Don't use Wordpad or such stuffs to do the job.
Additionally don't use any IDE to type and compile your
code. You'd better to learn to do it even without IDEs.


Then save the file in the Programs folder you've created as "startingJava.java". Run the Command Prompt and change the current path to the JDK's Progams folder. Type the following command and press Enter key:


javac startingJava.java


After a few seconds, Command Line would appear again while your
first Java program have been compiled. JVM (Java Virtual Machine)
now have created a class file for the program called startingJava.class .
The class file contains BYTE CODEs which is clearly similar to
Assembly codes. So there wouldn't be any .EXE file (executable file)
after compiling. For the next step, type the following command and
press Enter key:


java startingJava.class (or) java startingJava


Now the JRI (Java Runtime Interpreter) changes the byte codes to
the processors commands. You can see the output in this way:


This is my first Java Program.


Close the Command Prompt Window.


Cogratulations ! You made and compiled your first Java Program.
Now at the end of this article let me ask some question. I'm going to
answer them in the next article:



1. At first, why did we do those settings on Windows ?

2. While Interpreting .class file, why do you can type in the both
of the following ways? :


java .class (or) java


3. Why does the Java compiler make byte code instead of Assembly
code ?



In the next article we are going to start learning the Java's Basisc.



Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this tutorial
Comment Current Comments
by srinivas on Monday, September 5th 2005 at 01:54 AM

its good

by hhbayarea on Wednesday, September 28th 2005 at 05:18 PM

Adding path to User variables didn't work out on XP. Had to set path in command window.

Had to use public static void main(String[] args) instead of just public static void main to get rid of an error.

Overall, very good instructions.

by vinodreddy on Tuesday, December 20th 2005 at 08:52 AM

its really very good but i am not able to go to next page i suggest you to please provide next button to continue to next page

by HELP! on Saturday, January 21st 2006 at 10:25 AM

"error: cannot read: startingJava.java"

Wtf?

by naveed on Tuesday, January 24th 2006 at 09:05 AM

its very good.is it always necessary to write String ar[] coomand line argument?

by rasmin on Thursday, March 16th 2006 at 10:15 PM

thats really great

by Iyekeoretin on Friday, March 17th 2006 at 11:38 PM

thats really great
its very good

by mritunjay on Wednesday, July 5th 2006 at 04:59 AM

thats really great
its very good

by mritunjay on Wednesday, July 5th 2006 at 05:00 AM

thats really great
its very good

by FGDFG on Saturday, March 31st 2007 at 10:22 AM

VERY GOOD

by amita sharma on Wednesday, April 18th 2007 at 07:33 AM

good..but in the prog there is an error if we don\'t give the
main(string args[])
overall very friendly..


Comment Comment on this tutorial
Name: Email:
Message:
Comment Related Tutorials
There are no related tutorials.

Comment Related Source Code
There is no related source code.

Jobs Java Job Search
My skills include:
Enter a City:

Select a State:


Advanced Search >>
Sponsors
Discover Geekpedia

Other Resources