Jump to content

Into Java - Part I: Difference between revisions

From EDM2
mNo edit summary
Ak120 (talk | contribs)
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
By [[Simon Gronlund]]
{{IntoJava}}
''By [[Simon Grönlund]]''


{| width="400" cellpadding="4"
'''Summary:''' ''If our introductions to REXX have whet your appetite any, you may now be interested in moving up to another easy-to-learn language: Java.''
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part I|Part I]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part II|Part II]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part III|Part III]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part IV|Part IV]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part V|Part V]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part VI|Part VI]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part VII|Part VII]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part VIII|Part VIII]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part IX|Part IX]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part X|Part X]]
|}
 
{| width="400" cellpadding="4"
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part XI|Part XI]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part XII|Part XII]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part XIII|Part XIII]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part XIV|Part IV]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part XV|Part XV]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part XVI|Part XVI]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part XVII|Part XVII]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part XVIII|Part XVIII]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part XIX|Part XIX]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part XX|Part XX]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part XXI|Part XXI]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part XXII|Part XXII]]
| align="CENTER" valign="MIDDLE" |
[[Into Java - Part XXIII|Part XXIII]]
|}
 
'''Summary:''' ''If our introductions to Rexx have whet your appitite any, you may now be interested in moving up to another easy-to-learn language: Java.''


I doubt anyone has missed the Java wave, but maybe you are still wondering about what Java could do for you. If you'd like to find out, this new regular column will guide you into object oriented developing, try some useful algorithms and show how easy it could be to build graphical interfaces. Java makes all of the above easy, since most of the hard stuff has already been done and either comes with Java or is easy to obtain. In other words, Java gives you what you want, without the headache.
I doubt anyone has missed the Java wave, but maybe you are still wondering about what Java could do for you. If you'd like to find out, this new regular column will guide you into object oriented developing, try some useful algorithms and show how easy it could be to build graphical interfaces. Java makes all of the above easy, since most of the hard stuff has already been done and either comes with Java or is easy to obtain. In other words, Java gives you what you want, without the headache.


Soon we'll know more about Java inner parts, opportunities and user interaction, as well as basic modeling and design. I won't assume you have any knowledge about any particular programming technique, but I will assume you have some basic coding coding experience, no matter which language. In the future I'll be dividing future columns into a theory lesson and some practical lab work. But today we start with a little of Java's history.
Soon we'll know more about Java inner parts, opportunities and user interaction, as well as basic modelling and design. I won't assume you have any knowledge about any particular programming technique, but I will assume you have some basic coding coding experience, no matter which language. In the future I'll be dividing future columns into a theory lesson and some practical lab work. But today we start with a little of Java's history.


===The history lesson===
===The history lesson===
 
Once upon a time, while working for Sun Microcomputers, a computer scientist named [http://java.sun.com/people/jag/bio.html James Gosling] gave birth to a new object-oriented language that he named Oak. That was eight years back in 1991 when people were still using OS/2 version 1.30 and cheered when REXX made it into the Standard Edition. Oh, those were the days...
Once upon a time, while working for Sun Microcomputers, a computer scientist named [http://java.sun.com/people/jag/bio.html James Gosling] gave birth to a new object oriented language that he named Oak. That was eight years back in 1991 when people were still using OS/2 version 1.30 and cheered when Rexx made it into the Standard Edition. Oh, those were the days ...


Oak was primarily developed for use in embedded electronic equipment, such as VCRs, telephones and cable TV boxes. That never surfaced at the time, but it was important to the language because it set the basic characteristic of what we have today in Java. Two of those important qualities are size and reliability.
Oak was primarily developed for use in embedded electronic equipment, such as VCRs, telephones and cable TV boxes. That never surfaced at the time, but it was important to the language because it set the basic characteristic of what we have today in Java. Two of those important qualities are size and reliability.
Line 67: Line 15:
Embedded systems aren't equipped with huge amounts of memory, therefore the size is important. But even more important is the reliability. Imagine an automatic telephone switchboard running out of memory, or taking a sudden power-failure. You'd quickly learn to appreciate reliability if you lived in that area.
Embedded systems aren't equipped with huge amounts of memory, therefore the size is important. But even more important is the reliability. Imagine an automatic telephone switchboard running out of memory, or taking a sudden power-failure. You'd quickly learn to appreciate reliability if you lived in that area.


Fortunately, while consumer electronics were still far off, the World Wide Web gave Java a new purpose, since Java really met the needs of the client/server systems inherent to the Internet. The pro's were: the small size suited limited bandwidths, it was an interpreted language with the potential of being supported by any operating system, and it had a security manager. These made Java the perfect tool for applets and soon it was giving many web pages everything from animation to online shopping carts.
Fortunately, while consumer electronics were still far off, the World Wide Web gave Java a new purpose, since Java really met the needs of the client/server systems inherent to the Internet. The pros were: the small size suited limited bandwidths, it was an interpreted language with the potential of being supported by any operating system, and it had a security manager. These made Java the perfect tool for applets and soon it was giving many web pages everything from animation to online shopping carts.


What IBM saw in Java is still a mystery, since they already had Smalltalk, a language still widely used in the community of computer science and which still has a number of features Java doesn't have. In spite of that, March 1996 saw IBM gave us a prerelease of Java for OS/2, and six months later we received Warp 4 with Java 1.02. Today, we consider 1.02 useless, but back then it gave us a Java enabled Netscape and a token presence on the Java landscape. However, since then Java has matured from good to better to best on OS/2. If you've forgotten, why not look at [http://www.infoworld.com/cgi-bin/displayTC.pl?/980914analysis.htm Infoworld's] review of Java Virtual Machines again and see how OS/2 ranks compared to the others.
What IBM saw in Java is still a mystery, since they already had Smalltalk, a language still widely used in the community of computer science and which still has a number of features Java doesn't have. In spite of that, March 1996 saw IBM gave us a pre-release of Java for OS/2, and six months later we received Warp 4 with Java 1.02. Today, we consider 1.02 useless, but back then it gave us a Java enabled Netscape and a token presence on the Java landscape. However, since then Java has matured from good to better to best on OS/2. If you've forgotten, why not look at [http://books.google.com/books?id=vFEEAAAAMBAJ&pg=PA68 InfoWorld's review of Java Virtual Machines] again and see how OS/2 ranks compared to the others.


Today Java seems to be one of the hottest languages ever, broadly hyped-up by computer media and everyone except Microsoft. Nevertheless, learning Java could never be wrong, it gives you a deep insight in Object Oriented developing and you could always switch to C++ later on (given that the two languages are remarkably similar).
Today Java seems to be one of the hottest languages ever, broadly hyped-up by computer media and everyone except Microsoft. Nevertheless, learning Java could never be wrong, it gives you a deep insight in Object-Oriented developing and you could always switch to C++ later on (given that the two languages are remarkably similar).


===Java basics===
===Java basics===
As with REXX, Java is an interpreted language. This means that each instruction is translated into native machine code ''as it runs'' and your computer will need a Java interpreter to understand how to read each instruction.
As with REXX, Java is an interpreted language. This means that each instruction is translated into native machine code ''as it runs'' and your computer will need a Java interpreter to understand how to read each instruction.


But you ask, "Don't you compile the Java code?" Yes, you do, but you're not compiling to machine code as you would with a traditional compiled language. A computer understands machine code as you understand your native tongue, fast, fluently and faultless. Machine code speaks right to the computers heart, it's CPU. Only the operating system lays in between to control the actions, supporting the app with memory, creating windows on demand, and other basic tasks. But Java is compiled to a device-independent, operating system-independent, ''bytecode''.
But you ask, "Don't you compile the Java code?" Yes, you do, but you're not compiling to machine code as you would with a traditional compiled language. A computer understands machine code as you understand your native tongue, fast, fluently and faultless. Machine code speaks right to the computer's heart, it's CPU. Only the operating system lies in between to control the actions, supporting the app with memory, creating windows on demand, and other basic tasks. But Java is compiled to a device-independent, operating system-independent, ''bytecode''.


Bytecode (so-called because it is mostly made up by combinations of instructions of one or two bytes long) is kind of a pseudo-machine-language, understood by an interpreter, a Java Virtual Machine. The JVM reads the Java bytecode and executes it, byte by byte. The JVM '''is''', on the contrary, 100% dependent upon the actual operating system.
Bytecode (so-called because it is mostly made up by combinations of instructions of one or two bytes long) is kind of a pseudo-machine-language, understood by an interpreter, a Java Virtual Machine. The JVM reads the Java bytecode and executes it, byte by byte. The JVM '''is''', on the contrary, 100% dependent upon the actual operating system.


Compared to C this takes time and so Java has been belittled as sluggish. Alas, if you're planning to write yourself a new database managing the telephone numbers of New York city, you'd better pick another language. But, you could easily use Java to build your user-interface to this huge database as well as every module around it.
Compared to C this takes time and so Java has been belittled as sluggish. Alas, if you're planning to write yourself a new database managing the telephone numbers of New York City, you'd better pick another language. But, you could easily use Java to build your user-interface to this huge database as well as every module around it.


Further, Java can either be used to create a stand-alone application, or browser-dependent applets. The main difference is that you have to embed an applet in a HTML web page and run it in another framework, like your Netscape browser, or the OS/2 <tt>appletviewer</tt>. An application has no need of a framework, except the Java Virtual Machine that's installed on your computer. There are differences between apps and applets, but we'll not bother with these for the moment.
Further, Java can either be used to create a stand-alone application, or browser-dependent applets. The main difference is that you have to embed an applet in an HTML web page and run it in another framework, like your Netscape browser, or the OS/2 <tt>appletviewer</tt>. An application has no need of a framework, except the Java Virtual Machine that's installed on your computer. There are differences between apps and applets, but we'll not bother with these for the moment.


===Your Java developing environment===
===Your Java developing environment===
 
If you haven't already set up an environment for developing Java, there are only a few short steps you need to create one.
If you haven't already set up an environment for developing Java, there's only a few short steps you need to create one.


'''First'''. See to it you have at least one HPFS partition. When Java was developed, the designers thought it was about time to finally give up the old 8.3 filename limit, meaning that it's almost impossible to do any Java development on FAT formatted drives.
'''First'''. See to it you have at least one HPFS partition. When Java was developed, the designers thought it was about time to finally give up the old 8.3 filename limit, meaning that it's almost impossible to do any Java development on FAT formatted drives.
 
{| class="wikitable" align="right"
{| border="1" cellpadding="4" align="right"
!OS/2 - Window
| bgcolor="#000080" |
<font color="#ffffff">OS/2 - Window </font>
|-
|-
| bgcolor="#000000" valign="top" |
|
<font face="Helv,Helvetica,Arial"><font color="#ffffff">[C:\]md OS2-eZine_Java<br />[C:\]cd OS2-eZine_Java<br />[C:\OS2-eZine_Java]md HelloApp<br />[C:\OS2-eZine_Java]cd HelloApp<br />[C:\OS2-eZine_Java\HelloApp] </font></font>
[C:\]md OS2-eZine_Java
[C:\]cd OS2-eZine_Java
[C:\OS2-eZine_Java]md HelloApp
[C:\OS2-eZine_Java]cd HelloApp
[C:\OS2-eZine_Java\HelloApp]
|-
|-
| valign="bottom" |
|''Figure 1. Make yourself some new folders to use.''
Figure 1. Make yourself some new folders to use.
|}
|}
'''Second'''. Make yourself a new folder to use for your work (Figure 1). We'll use several examples and a lot of the stuff will be reused, as it should in object-oriented developing.


'''Second'''. Make yourself a new folder to use for your work (Figure 1). We'll use several examples and a lot of the stuff will be reused, as it should in object oriented developing.
Although there are a number of visual developing tools available, you are in no need of them now. They serve their purpose, but I want you to get the basic feeling of Java inner parts. Frankly, you got the first tool already, E.EXE, which comes with OS/2. Or you could use EPM, or any tool you find yourself comfortable with. The advantages with developing tools are, you'll get coloured keywords, automatic indentation and other nifty features.
 
Although there are a number of visual developing tools available, you are in no need of them now. They serve their purpose, but I want you to get the basic feeling of Java inner parts. Frankly, you got the first tool already, E.EXE, which comes with OS/2. Or you could use EPM, or any tool you find yourself comfortable with. The advantages with developing tools are, you'll get colored key words, automatic indentation and other nifty features.


'''Third'''. Go get the software needed. To install Java you are in need of a few items. Follow these steps:
'''Third'''. Go get the software needed. To install Java you are in need of a few items. Follow these steps:
 
* Get up an early Saturday morning, when every other web surfer is asleep. Bring your biggest coffee Thermos, a virtual shopping bag and plan for a '''long''' download (unless you've got a T1 line). Point your browser to [http://service.software.ibm.com/asd-bin/doc/ OS/2 Software Choice] and choose your language.
* Get up an early Saturday morning, when every other web surfer is asleep. Bring your biggest coffee thermos, a virtual shopping bag and plan for a '''long''' download (unless you've got a T1 line). Point your browser to [http://service.software.ibm.com/asd-bin/doc/ OS/2 Software Choice] and choose your language.
* If you haven't got the freshest version of Netscape, get it now, you'll need it later on.
* If you haven't got the freshest version of Netscape, get it now, you'll need it later on.
* Put "OS/2 Feature Install Version 1.2.3" in your bag. (And don't ask me why IBM want us to do it this way).
* Put "OS/2 Feature Install Version 1.2.3" in your bag. (And don't ask me why IBM want us to do it this way).
Line 117: Line 62:
*# Now unzip the '''two''' Java files into one temporary folder, and then run <tt>INSTALL.EXE</tt>. Follow the instructions you'll get. After install is finished, shut down your computer and reboot. At last, delete the contents of the temporary directories.
*# Now unzip the '''two''' Java files into one temporary folder, and then run <tt>INSTALL.EXE</tt>. Follow the instructions you'll get. After install is finished, shut down your computer and reboot. At last, delete the contents of the temporary directories.
* Now point your browser to ftp://ftp.hursley.ibm.com/pub/java/fixes/os2/11/117/ to get the latest fixes for Java. Three files. Yes, they are big, but they are worth it. As of writing this, the latest version is "JDK 1.1.7A IBM build o117-19990218".
* Now point your browser to ftp://ftp.hursley.ibm.com/pub/java/fixes/os2/11/117/ to get the latest fixes for Java. Three files. Yes, they are big, but they are worth it. As of writing this, the latest version is "JDK 1.1.7A IBM build o117-19990218".
* Copy these files to the root on the drive where you have the <tt>JAVA11</tt> folder, not in that folder but in the root, such as C:\. Execute them, starting with <tt>RUNTIME.EXE</tt>, then <tt>TOOLKIT.EXE</tt> and <tt>SAMPLES.EXE</tt>. These are self-extracting files that had their directory structures kept intact, making them unpack their files to where you should have installed Java.
* Copy these files to the root of the drive where you have the <tt>JAVA11</tt> folder, not in that folder but in the root, such as C:\. Execute them, starting with <tt>RUNTIME.EXE</tt>, then <tt>TOOLKIT.EXE</tt> and <tt>SAMPLES.EXE</tt>. These are self-extracting files that had their directory structures kept intact, making them unpack their files to where you should have installed Java.


===Say Hello World===
===Say Hello World===
[[Image:java1.gif]]
[[Image:java1.gif]]


Line 128: Line 72:


Be sure you save the file with exactly this name in your HelloWorld folder that you made before: <tt>HelloWorld.java</tt>. Java is very sensitive with upper and lower case names, including file names.
Be sure you save the file with exactly this name in your HelloWorld folder that you made before: <tt>HelloWorld.java</tt>. Java is very sensitive with upper and lower case names, including file names.
 
{|class="wikitable" align="right"
After you've written the code and saved it, you're off to execute the built in Java compiler. And after that we will test the OS/2 JVM (Figure 3).
!OS/2 - Window
 
The first command line <tt>javac HelloWorld.java</tt> starts the Java compiler. The result will be a new file called <tt>HelloWorld.class</tt>.
 
{| border="1" cellpadding="4" align="right"
| bgcolor="#000080" |
<font color="#ffffff">OS/2 - Window </font>
|-
|-
| bgcolor="#000000" valign="top" |
|
<font color="#ffffff">[X:\]<br />[X:\]javac HelloWorld.java<br />[X:\]java HelloWorld<br />Hello World! </font>
[X:\]
 
[X:\]javac HelloWorld.java
<font color="#ffffff">[X:\] </font>
[X:\]java HelloWorld
Hello World!
[X:\]
|-
|-
| valign="bottom" |
|''Figure 3. Compile and run your first Java app.''
Figure 3. Compile and run your first Java app.
|}
|}
After you've written the code and saved it, you're off to execute the built-in Java compiler. And after that we will test the OS/2 JVM (Figure 3).
The first command line <tt>javac HelloWorld.java</tt> starts the Java compiler. The result will be a new file called <tt>HelloWorld.class</tt>.


The second command line <tt>java HelloWorld</tt> is actually starting the OS/2 JVM, executing the file <tt>HelloWorld.class</tt>. The extension 'class' is always omitted.
The second command line <tt>java HelloWorld</tt> is actually starting the OS/2 JVM, executing the file <tt>HelloWorld.class</tt>. The extension 'class' is always omitted.
Line 150: Line 93:
Now you could go tell your friends you've spent this time making a Java application ;-)
Now you could go tell your friends you've spent this time making a Java application ;-)


Did I hear someone mention "useful"? Ahem, could we save some of the goodies to the future? So you will be back. See you next month!
Did I hear someone mention "useful"? Ahem, could we save some of the goodies for the future? So you will be back. See you next month!


[[Category:Languages Articles]]
[[Category:Java Articles]]

Latest revision as of 02:12, 24 September 2022

Into Java / Part
I II III IV V VI VII VIII IX X XI XII
XIII IV XV XVI XVII XVIII XIX XX XXI XXII XXIII

By Simon Grönlund

Summary: If our introductions to REXX have whet your appetite any, you may now be interested in moving up to another easy-to-learn language: Java.

I doubt anyone has missed the Java wave, but maybe you are still wondering about what Java could do for you. If you'd like to find out, this new regular column will guide you into object oriented developing, try some useful algorithms and show how easy it could be to build graphical interfaces. Java makes all of the above easy, since most of the hard stuff has already been done and either comes with Java or is easy to obtain. In other words, Java gives you what you want, without the headache.

Soon we'll know more about Java inner parts, opportunities and user interaction, as well as basic modelling and design. I won't assume you have any knowledge about any particular programming technique, but I will assume you have some basic coding coding experience, no matter which language. In the future I'll be dividing future columns into a theory lesson and some practical lab work. But today we start with a little of Java's history.

The history lesson

Once upon a time, while working for Sun Microcomputers, a computer scientist named James Gosling gave birth to a new object-oriented language that he named Oak. That was eight years back in 1991 when people were still using OS/2 version 1.30 and cheered when REXX made it into the Standard Edition. Oh, those were the days...

Oak was primarily developed for use in embedded electronic equipment, such as VCRs, telephones and cable TV boxes. That never surfaced at the time, but it was important to the language because it set the basic characteristic of what we have today in Java. Two of those important qualities are size and reliability.

Embedded systems aren't equipped with huge amounts of memory, therefore the size is important. But even more important is the reliability. Imagine an automatic telephone switchboard running out of memory, or taking a sudden power-failure. You'd quickly learn to appreciate reliability if you lived in that area.

Fortunately, while consumer electronics were still far off, the World Wide Web gave Java a new purpose, since Java really met the needs of the client/server systems inherent to the Internet. The pros were: the small size suited limited bandwidths, it was an interpreted language with the potential of being supported by any operating system, and it had a security manager. These made Java the perfect tool for applets and soon it was giving many web pages everything from animation to online shopping carts.

What IBM saw in Java is still a mystery, since they already had Smalltalk, a language still widely used in the community of computer science and which still has a number of features Java doesn't have. In spite of that, March 1996 saw IBM gave us a pre-release of Java for OS/2, and six months later we received Warp 4 with Java 1.02. Today, we consider 1.02 useless, but back then it gave us a Java enabled Netscape and a token presence on the Java landscape. However, since then Java has matured from good to better to best on OS/2. If you've forgotten, why not look at InfoWorld's review of Java Virtual Machines again and see how OS/2 ranks compared to the others.

Today Java seems to be one of the hottest languages ever, broadly hyped-up by computer media and everyone except Microsoft. Nevertheless, learning Java could never be wrong, it gives you a deep insight in Object-Oriented developing and you could always switch to C++ later on (given that the two languages are remarkably similar).

Java basics

As with REXX, Java is an interpreted language. This means that each instruction is translated into native machine code as it runs and your computer will need a Java interpreter to understand how to read each instruction.

But you ask, "Don't you compile the Java code?" Yes, you do, but you're not compiling to machine code as you would with a traditional compiled language. A computer understands machine code as you understand your native tongue, fast, fluently and faultless. Machine code speaks right to the computer's heart, it's CPU. Only the operating system lies in between to control the actions, supporting the app with memory, creating windows on demand, and other basic tasks. But Java is compiled to a device-independent, operating system-independent, bytecode.

Bytecode (so-called because it is mostly made up by combinations of instructions of one or two bytes long) is kind of a pseudo-machine-language, understood by an interpreter, a Java Virtual Machine. The JVM reads the Java bytecode and executes it, byte by byte. The JVM is, on the contrary, 100% dependent upon the actual operating system.

Compared to C this takes time and so Java has been belittled as sluggish. Alas, if you're planning to write yourself a new database managing the telephone numbers of New York City, you'd better pick another language. But, you could easily use Java to build your user-interface to this huge database as well as every module around it.

Further, Java can either be used to create a stand-alone application, or browser-dependent applets. The main difference is that you have to embed an applet in an HTML web page and run it in another framework, like your Netscape browser, or the OS/2 appletviewer. An application has no need of a framework, except the Java Virtual Machine that's installed on your computer. There are differences between apps and applets, but we'll not bother with these for the moment.

Your Java developing environment

If you haven't already set up an environment for developing Java, there are only a few short steps you need to create one.

First. See to it you have at least one HPFS partition. When Java was developed, the designers thought it was about time to finally give up the old 8.3 filename limit, meaning that it's almost impossible to do any Java development on FAT formatted drives.

OS/2 - Window
[C:\]md OS2-eZine_Java
[C:\]cd OS2-eZine_Java
[C:\OS2-eZine_Java]md HelloApp
[C:\OS2-eZine_Java]cd HelloApp
[C:\OS2-eZine_Java\HelloApp]
Figure 1. Make yourself some new folders to use.

Second. Make yourself a new folder to use for your work (Figure 1). We'll use several examples and a lot of the stuff will be reused, as it should in object-oriented developing.

Although there are a number of visual developing tools available, you are in no need of them now. They serve their purpose, but I want you to get the basic feeling of Java inner parts. Frankly, you got the first tool already, E.EXE, which comes with OS/2. Or you could use EPM, or any tool you find yourself comfortable with. The advantages with developing tools are, you'll get coloured keywords, automatic indentation and other nifty features.

Third. Go get the software needed. To install Java you are in need of a few items. Follow these steps:

  • Get up an early Saturday morning, when every other web surfer is asleep. Bring your biggest coffee Thermos, a virtual shopping bag and plan for a long download (unless you've got a T1 line). Point your browser to OS/2 Software Choice and choose your language.
  • If you haven't got the freshest version of Netscape, get it now, you'll need it later on.
  • Put "OS/2 Feature Install Version 1.2.3" in your bag. (And don't ask me why IBM want us to do it this way).
  • Then grab Java 1.1.7. Get the "Java Runtime Package" (and if International languages aren't your priority, get the one without the Unicode font, since it's 12 megabytes more), and the "Developer Package".
  • After you've downloaded that, and shattered your stomach with way too much coffee, you have to install the stuff. Do it in the same order you downloaded the files:
    1. If you had to get Netscape Communicator, execute the self extracting file in a temporary folder and follow the instructions (mainly, run install, then reboot).
    2. Now for Feature Install, which you unzip it into another temporary folder and then run FISETUP.EXE. This adds a plugin to Netscape for use by the HTML-based Java install program.
    3. Now unzip the two Java files into one temporary folder, and then run INSTALL.EXE. Follow the instructions you'll get. After install is finished, shut down your computer and reboot. At last, delete the contents of the temporary directories.
  • Now point your browser to ftp://ftp.hursley.ibm.com/pub/java/fixes/os2/11/117/ to get the latest fixes for Java. Three files. Yes, they are big, but they are worth it. As of writing this, the latest version is "JDK 1.1.7A IBM build o117-19990218".
  • Copy these files to the root of the drive where you have the JAVA11 folder, not in that folder but in the root, such as C:\. Execute them, starting with RUNTIME.EXE, then TOOLKIT.EXE and SAMPLES.EXE. These are self-extracting files that had their directory structures kept intact, making them unpack their files to where you should have installed Java.

Say Hello World

We will conclude this first part of our column with the most oft written application ever: "Hello World." Open up an OS/2 window alongside your text or programming editor of choice (in our case, MED), then follow me.

Our "Hello World" example is shown here in this screenshot, (Figure 2) that's deliberately replacing normal text so you can't cheat by using cut and paste ;-) Remember that Java is sensitive to the type of parentheses or bracket you use, with there being three kinds: { } [ ] ( ). They are always in pairs.

Be sure you save the file with exactly this name in your HelloWorld folder that you made before: HelloWorld.java. Java is very sensitive with upper and lower case names, including file names.

OS/2 - Window
[X:\]
[X:\]javac HelloWorld.java
[X:\]java HelloWorld
Hello World!

[X:\]
Figure 3. Compile and run your first Java app.

After you've written the code and saved it, you're off to execute the built-in Java compiler. And after that we will test the OS/2 JVM (Figure 3).

The first command line javac HelloWorld.java starts the Java compiler. The result will be a new file called HelloWorld.class.

The second command line java HelloWorld is actually starting the OS/2 JVM, executing the file HelloWorld.class. The extension 'class' is always omitted.

Now you could go tell your friends you've spent this time making a Java application ;-)

Did I hear someone mention "useful"? Ahem, could we save some of the goodies for the future? So you will be back. See you next month!