A short introduction to Java programming

Sunday Nov 8th 1998 by ServerWatch Staff

Whatever you do ... intranet applications, commercial presentation or only your home page, it is very important to have an impeccable presentation, that means some special buttons, help, dynamic pictures, some animations and sounds. You can do all of this and much more with Java applets and/or JavaScripts

by Sebastian Bologescu

Hi to all of you!

My name is Sebastian Bologescu and I think it is a good idea to give you some useful hints which can make you become interested in Java programming.

First of all I'll introduce myself:
I am 24 years old, and I just finished Computer Science Dept. of University "Poitehnica" here in Bucharest. Between 15 nov 1997 and 1 June 1999, I worked for Media Pro International, the largest television company from Romania. Currenly I am working with Techdomain, as a member of their IT consulting group. Using my knowledge I implemented a system for news acquisition from four news agencies via sattelite. But this will be another subject about ASP programming.
If you want to know more about me, please look here for my CV.
If you are a company and you want to develop some in-house project don't hesitate to contact Techdomain team!!!

A short introduction to Java programming

Whatever you do ... intranet applications, commercial presentation or only your home page, it is very important to have an impeccable presentation, that means some special buttons, help, dynamic pictures, some animations and sounds. You can do all of this and much more with Java applets and/or JavaScripts.


Java applets: a small piece of executable code (compiled)which is downloaded from HTTP server to your web client and is executed through your Virtual Java Machine.

Virtual Java Machine: a software emulated processor which knows to execute your applet in context with your browser.

Java Scripts: interpretable code (script) which doesn't need to be compiled. This script is interpreted by the browser during run-time.

Java applications: something like applets, but is browser independent (different window, different menus etc.).

Methods: this is the name for functions from a class - it is like behaviour of an object

Members: the variables from a class or method - is like a properties of an object

What do I need for Java programming?

First off all you need a computer! After that you must buy a Java Compiler. For this I recommend you Visual J++ from Microsoft or Symantec Cafe from Symantec (very optimized code).

Java programming

The code is very similar to C++. The operators and the statements are all the same. The difference is that, in Java you don't declare prototypes. The source file has *.java extension and executable file has *.class extension.
From my view, the best way to learn Java is to take a concrete problem to resolve.

Let's go to do this applet:   

As you see, you can draw two types of elements (strings) selecting it with a button. It is a simple and useless applet but it is important in educational sense.

This is the sample code:

For Java compiler I used Symantec Cafe 1.5.

Java is an object oriented language, that means the secret in doing good code is to understand, and to know the structure of classes. For that I suggest to look in Symantec Cafe at browse tag to see this structure, or consult java documentation from any java compiler. I can't describe all this structure from Symantec Cafe here becouse I'll need all the harddisk space from swynk.com!!! :)

First thing we must do is to declare the libraries we use in our applet.

In this case we have to include java.awt.*; and java.applet.Applet. That means we will make accessible for us all classes from java.awt (used for layout manager to handle events and so on ...) and Applet class. Applet is the class from where we derive our own class (in this case, CFirst).
After that we will define our new class (CFirst). That class is derived from Applet, that means all methods and members of Applet are available to us. The new class declaration is:

public class CFirst extends Applet


// class personalize (override methods, add new members etc...)


All we need to do right now, is to personalize some of that methods overriding them.
I will declare some members (variables):

int xb=0, yb=0; - integer variables needed to store the last mouse cursor position in rectangular coordinates

String txt=""; - string variable used to set the text we display (in this case 'Computer' or 'Server')

Button b1, b2; - two objects from Button class.

We need to put two buttons so we'll override the init() method. Why init() method? Because that method is the entry point in our programm when applet is executed (initialized).
The declaration for init() member is:

public void init() - is a public method (can be accesed from outside) and don't have return or parameters (very similar to C++).

Here we will initialize the b1 and b2 object. We do this using Button(String label )  - the constructor for class Button. Label parameter define the label for the button and is of string type.
After that we display our new defined buttons (b1, b2) with ...

add(b1); - add first button, something like this .... and ...

add(b2); - add first button, something like this .... but as you see when we click on it nothing happens!!!

So we are finished with initialization part.

Now we need to see when a button is clicked. For this we have a lot of methods in class Applet which can handle this kind of events:

public boolean action(Event e, Object arg) - this method return a boolean value and have two parameters.

Event e - the event which happens

Object arg - the arguments associated with event.

When an event appears, the Windows send a message to our applet. In this case the method action is called. Depending on the button pressed, we will set the txt variable with the coresponding string.
In the same way we'll use "mouse drag" and "mouse up" events which are other methods treating mouse events.
At mouse drag, we need to move the text on the screen. We override the last position with background color (lightGray) and draw it on new position with blue.
At "mouse up" event, I reset the xb and yb coordinates, so that the text will not be erased on next mouse drag.
To put the applet in your .html or .asp page you need to write the following tag:

<applet code="CFirst" name="MyApplet">


That's all folks! ...

... But OOOPS, we have some problems!!! Try to move or minimize-maximize the window with your applet. As you can see all you draw in applet's window dissapear. This is normal, because when Windows refresh our window reset it, so we loose all. To preserve the text we need to redraw it after refresh.

Name: Sebastian Cristian BOLOGESCU

Date and place of birth: 25th November 1974 in Braila, Romania.

Address: Braila, 311bis Dorobantilor street, 6th floor, ap.26, Romania
                phone +4039.631.577, +4094.821.085

1981 – 1989, art school in Braila (drawing and paint – first graduate)
1989 - 1993, “Gh. M. Murgoci” high-school, mathematics-physics profile;
1993 - 1998, University of Automatics and Computers Science Bucharest

Professional activity:
- October 1996 – July 1997, Circle Systems International – Bucharest - engineering, help desk, network projects
- October 1997 – November 1997, Striz Trading Company – Bucharest - sales agent and database computer
- from November 1997 at Media Pro International – Bucharest - database intranet application developer, NT & Novell administrator, hardware and help desk

My actual job at MPI consist in:

Programming (principal activity)
- NT services for news acquisition from satellite (APTV, AFP, WTN, Reuters) – programmed with MSVC++
- intranet applications with SQL data bases for news view (ASP, Java)
- intranet applications for monitoring and maintain SQL data bases

Novell 4.11 administrator
- servers shape
- create new accounts
- purge and maintain volumes (critical utilization)
- maintain e-mail application (Funny SMTP)

NT server 4.0, SQL server & HTTP server administrator (principal activity)
- install, maintain
- create new accounts
- Dial-Up server maintain
- intranet applications maintain

- configure network and local printers
- recover lost files
- help users for particular troubles
- install and configure new systems (operating systems, MS Office, etc.)
- install and configure new clients for Novell, Microsoft Networking etc.

Support network
- CAT 5 structured cabling
- outlet mounting / patch panel (S110, RJ45)
- network testing
- traffic monitoring on specific segments (straighten out)

- diagnosis and repair damaged computers
- install and configure new components.

Foreign languages:
English – very good
French – beginner

Fields of interesting:
Interested in internet/intranet development (HTML, ASP, VBScript, Jscript, Java, Visual C++, SQL, Oracle), database application under WinNT4.0 with MSSQL6.5

Very fast learning, good team worker, serious. Very strong background in ASP and Java programming.

Back to the Article

Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved