Copyright (c) 1999 by Charlie Calvert
In this chapter you will learn how to set up JBuilder. l will also discuss the terminology you need to begin reading about programming in JBuilder. I will also show how to customize your programming environment to meet your needs.
This is one chapter that I will almost certainly be expanding during the development of this text. I expect to get feedback describing problems that people have setting up and configuring JBuilder. Only marketing slime in the clutches of an extreme obsession would dare to imply otherwise. I am, however, definitely not a tech support install resource. I cannot answer your personal questions about install issues. I can however, update this text to reveal new information that might be valuable to readers. You might, therefore, want to check back here frequently to look for updates.
The install process is described on the Borland web site at the following address:
http://www.borland.com/jbuilder/foundation/
The notes I include here are meant to be additions and clarifications on the install process. Please write me if you run across specific problems that are not covered in my notes. Do not, however, expect to get support from this source. I'm only interested in hearing about problems that might be of interest to other readers.
Remember that my focus in this series of articles is on the Linux version of Java. At a later point, I may include information about the Windows install of the product, but for now I'm focusing on Linux. In particular, I'm using Red Hat Linux 6.0.
On the Intel platforms, I believe JBuilder starts being useful on a 233 MHZ or above machine. You will also want at least 96 MB of RAM. These aren't the minimum requirements, they are just my personal view of what you need to feel moderately comfortable with this tool. There is no question that you will be happier if you have a 400 MHZ or better machine, and at least 128 MB of ram.
At this time I'm doing most of my development on a 350 MHZ Cyrix Linux machine with 96 MB of RAM. It could be faster, but I don't find it particularly painful. I also use an NT 2000 laptop with a 266 MHZ processor and 196 MB of RAM. Because of the RAM, that machine handles JBuilder fairly well. At home I have a 600 MHZ Athlon machine with 128 MB of RAM running Windows 98. At work, I focus on the Linux machine, but on the weekends and evenings I put in some serious programming hours on the Athlon. The laptop is mostly for word processing (now done entirely in HTML) and programming in Delphi.
I installed my copy of the JDK in my /usr/local directory. To do this, I needed to sign on as root. I used the cp command to copy the downloaded version of the Linux 1.2.2 SDK to my /usr/local directory. In a command window, I then typed:
tar xvzf jdk1_2_2rc1-linux-i386.tar.gz
This single command unzipped and untarred the contents of the JDK into the /usr/local/JDK 1.2.2/ directory. The following commands will do the same thing in two steps:
gunzip jdk1_2_2rc1-linux-i386.tar.gztar xvf jdk1_2_2rc1-linux-i386.tarAfter installing the JDK, I decided that I wanted to be able to easily access the JDK from a command window. To do this, I logged out and logged back in as a less powerful user named -- naturally -- ccalvert. I went to the /home/ccalvert directory and added the following line to the .bashrc file:
PATH=/usr/local/jdk1.2.2/bin:$PATH
When I was done, my .bashrc file looked like this:
# .bashrc # User specific aliases and functions alias ls="ls --color=always" # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi PATH=/usr/local/jdk1.2.2/bin:$PATH
To test my configuration, I went to the command line and typed javac. The help screen for the javac compiler appeared on my screen when I did that. I then typed java -version, and saw that it was indeed JDK 1.2.2 that I was using.
It is of course fine to have other versions of the JDK installed on your system. You can just change the path to access the different versions you want to use.
I did not log in as root when I installed JBuilder. Instead, I stayed logged in as ccalvert. I would recommend that you also do not install JBuilder when you are logged in as root. To do so can cause conflicts later, when you try to access JBuilder as another user.
I use JBuilder under KDE, and for now, I would recommend that you do the same. JBuilder runs fine under other windowing schemes, but it seemed to have a particularly friendly relationship with KDE. For instance, the icon for JBuilder was automatically installed on the desktop when I used KDE, but it was not there when I was switched over to GNOME. If you are using the Red Hat install, you can go to the command prompt and type switchdesk to run a utility that will quickly switch you from GNOME to KDE. You can issue the same command to switch back again if you so desire.
I copied my JBuilder install file that I downloaded from the web to the /home/ccalvert directory. I then ran tar -xvfz against the file I downloaded form the Borland site. A directory called no_vm was created. I moved into that directory, and typed sh install.bin. The rest of the install proceeded automatically. The only question I had to answer was where I wanted to install JBuilder, and I choose a directory called /home/ccalvert/JBuilder.
I then returned to the KDE desktop, where I found my JBuilder icon. I clicked once on the icon, and a few moments later I was able to begin programming.
Assuming that you now have JBuilder installed, the next step is to develop a vocabulary for describing the environment. This section of the text is dedicated to giving you that terminology. When we are done defining our terms, we can use our shared knowledge to describe the various tools found in the JBuilder IDE.
Naturally enough, the first term on the list is IDE. An IDE is an Integrated Development Environment. The Development Environment part of the term means that the IDE is a program that can be used to develop applications (or applets.)
The Integrated part of the acronym IDE means that JBuilder has an integrated set of development tools. In particular, it combines an editor with a debugger. There are, however, a number of other important tools that are part of the environment, including a code browser, numerous wizards, and a context sensitive help system. The help system even has an extension called code insight that will allow you to automatically discover the methods of objects at run time without having to look in the help. I will explain more about how that works later.
Borland is famous for creating good IDEs. JBuilder Foundation is important because it allows developers on the Linux and Solaris platforms to begin using a truly powerful IDE.
The next step in our journey is to become familiar with the main parts of the IDE. For now, I'm going to keep this examination at a fairly high level. A more detailed look will be added to this chapter at a later time.
Open up JBuilder and choose File | Close Project. This ensures that any projects in the IDE are closed. Now choose File | New. A dialog will appear. You have the option to create a new Project, Application or Applet. Choose New Applet. A dialog will come up. Click the finish button. When you are done the screen should look something like it does in Figure 1.
Figure 1: The JBuilder environment with a project loaded in it.
The top of the environment contains the menus and set of small icons that are collectively called the toolbar. The main items on the toolbar allow you to open and close projects, to save files or projects, and to compile and run your project.
Beneath the toolbar is the editor/debugger. The editor is divided into three sections. The main part of the editor, where you see your source code and html files, is called the content pane, or sometimes simply the editor.
To the left of the editor are two windows called the navigation pane and the structure pane. The navigation pane contains a list of the files in your project. The structure pane shows the classes, imports and variables declared in your source files. For instance, in Figure1, Applet1.java is one of the files in a project, so it shows up in the navigation pane. In the structure pane you can see that Applet1 is the name of one of the classes in your project. The Applet1 class has methods called getAppletInfo, getParameter, etc. For now, it is not important that you understand what all these words mean. All you have to get at this point is that you can see the files in your project, and you can browse the classes declared in your files. Even if you don't know what a class is, that's still okay. I'm going to explain these things later. For now, just get a feeling for how the IDE is structured.
If you select an HTML file in the content pane, then the structure pane will disappear. To try this out, double click on Applet1.html. When you do this, the structure pane disappears, as shown in Figure2. That is because JBuilder does nothing to help you parse the content of an HTML file. JBuilder has a built in HTML browser, which you can see in Figure2. If you press the source tab beneath the browser, then you can see the source for the HTML.
If you select a Java source file, the structure pane appears again, and you can use it to view the classes and elements of your program, as shown in Figure1.
Figure 2: The structure pane disappears when you view an HTML file.
There are two ways to select a file in the navigation pane. You can double click on the file, or you can right click on the filename, and select Open from the menu. In JBuilder foundation running on Linux, I found that the Open command was more reliable.
There are two changes you can make to the JBuilder environment if you want the code you create to look like mine. Both of these changes are optional, and I suggest you do this only so you can more easily follow my examples. In other words, I'm not suggesting that my way of doing things is better than other ways, I'm just letting you understand what I've done to customize my environment. If you choose to make the same changes I made, then you can more easily follow with my examples.
On the Project menu, choose Default Project Options and turn to the Code Style page, as shown in Figure 3.
Figure 3: Configuring JBuilder with the Code Styles page.
The Code Style page is dived into two main sections called Braces and Event Handling. In the Braces section, choose Next Line. This option tells JBuilder to produce code that looks like this:
void Foo()
{
}
If you select the default option, your code will look like this:
void Foo() {
}
Neither technique is wrong. You can choose the one that you prefer. In suppose that most Java programmers choose the default option, but I like the Next Line style. I find the second style easier to read. In the long run, creating code that is easy to read can be a great benefit both to yourself and others. In fact, I think creating easy to read code is one of the most important things you can do as a developer. Of course, its not as important as writing code that works, but it is still very important.
On the Code Styles page, I recommend you also select Standard adaptor rather than Anonymous adaptor. I like this option because it is easy for me to read, and I also believe it will be easier for you to understand.
NOTE: I understand that you, as a beginning programmer, or as someone new to JBuilder, may not understand anything at all about adaptors, or even about braces. If so, that is fine. The point here is simply to set up your environment properly. You can worry about the other details later.
At this stage you have done all you need to get started with JBuilder Foundation. You can now go onto the next chapter and learn how to write a simple Applet.
Checking to Make Sure Basic Applets and Applications Run
Choose the following keystrokes:
File|New
Application|OK
Finish
Finish
Run(F9)
If this allows you to run a simple application, then things are set up correctly on your system.
In this chapter you learned how to install JBuilder, and learned a few basic terms that are necessary for an understanding of the remaining chapters in this text. At the end of the chapter, I also added a few notes explaining how I have customized my environment. Even if you choose other options than those I have outlined here, I would hope that you can still use these notes as a jumping off place when figuring out how to set up the environment to suit your own purposes.