Go to: Search
FIB > Computing laboratory > FAQ > Java Català | Castellano


Generals
Unix/Linux
Windows and PC
Java
Electronic mail
Remote connection
Connection between systems
The Website, El Raco and personal webpages
Final Thesis support



Java

Last modified: 14-06-2002


1.- Installing JDK (Java Development Kit)


2.- How JDK works


3.- General problems


1.- Installing JDK (Java Development Kit)

1.1 What is JDK?

R: JDK (Java Development Kit) is the package of programs for developing and running Java applications. It offers the possibility of running them in the Internet browser or independently, depending on the type of application you wish to create.

1.2 How do I get JDK?

R: JDK is completely free, and the latest version is available for download at the Sun Microsystems website.The School's network offers both Windows and Linux versions, together with the corresponding documentation.
All versions are in G:\Java\Zip\ \ . It is not necessary to copy the whole contents of the folder (partly because of its size), since you only need one of the versions in order to compile and run programs written in Java. Below there is a table that shows all the necessary files for each operating system.
 

- for Linux (G:\Java\Zip\Linux)

JDK 1.1.7

README.linux
jdk_1.1.7-v3-glibc-x86.tar.gz
jre_1.1.7-v3-glibc-x86.tar.gz

Documentation for installing JDK on Linux in English
JDK 1.1.7 executables
Java RunTime Environment 1.1.7. Virtual Java machine for running programs written in Java

- for Windows (G:\Java\Zip)

JDK 1.1.8

jdk1_1_8-win.exe
jdk118-doc.zip

JDK 1.1.8 executables
JDK 1.1.8 documentation

JDK 1.2.2

jdk1_2_2-win.exe
jdk1_2_2-doc.zip

JDK 1.2.2 executables
JDK 1.2.2 documentation

Currently, the Linux PC network is loading JDK 1.1.7, and Windows is loading JDK 1.1.8 and JDK 1.2.2. With respect to the IP practicals, the newer versions (1.2.2) are compatible with Versions 1.1.7 and 1.1.8.

1.3 How do I install JDK on my computer?

R: Windows installation.
Windows is simple to install. All you need to do is copy the executable file onto your hard disk, and double-click on the icon. It installs automatically, and asks which folder to use. Once this is done, all you have to do is edit AUTOEXEC.BAT, which is usually in the root directory: C:\ \ . First, you must add the following line at the end of the file:

        SET PATH=%PATH%;[JDK_folder]\BIN

where [JDK_folder] is the folder where JDK is installed. For example, if C:\JDK is the folder you used to install the program, AUTOEXEC.BAT should include the line: SET PATH=%PATH%;C:\JDK\BIN. The documentation is independent from the program. It need not be in the same folder as JDK.

R: Linux installation
Linux is also quite simple to install, but you must make sure you use the version that is compatible with the environment you have chosen to work with. In order to install is correctly, you must follow the instructions given in the file README.linux, which you will find in G:\Java\Zip\Linux.

2.- How JDK works

2.1 How do I edit Java code?

R: You can edit Java code in any text editor that can output text files. The files must have the extension .java. You can do this by simply renaming the file as file_name.java, or by using the "save as" option that is available in most editors.
There is a Windows editor called FreeJava that serves to edit, compile, and run Java code all in the same environment. In case anyone is interested, there is a version of emacs for Windows.

2.2 How do I compile Java code?

R: In order to compile Java code you need to install JDK and modify autoexec.bat, as explained in point 1. Once you have all necessary files, you need only type the Javac command along with the file name.

        javac [file_name].java

2.3 how do I run Java applications?

R: This depends on the type of application you are writing.
If the application is written to be run from the command line, like an independent program on the Web, then run it using the Java command

        java [file_name]

If the application is an applet, there is a JDK tool for viewing applets. This tool is actually a browser, but it is so basic that it only understands the tag <APPLET ... </APPLET. The tool is called appletviewer. The parameter you give it is not the Java applet itself, but a web page that contains an applet somewhere in the code.

        appletviewer [file_name].html

2.4 How do I run and work with JDK at the School in Windows?

R: Depending on the version you want to work with, type:

        INIJDK x

where x is 1 for Version 1.1.7; or x is 3 if you want to use Version 1.2.2.

3.- General problems

3.1 Notes

R: Java is case-sensitive. Although useful, this is the source of many head-aches when compiling code, since it is quite easy to overlook the fact that a variable is typed in two different cases. If your code won't compile, check that all of the variables are written correctly.

3.2 I'm trying to run Javac or Java and it doesn't work. How do I solve this problem?

R: This is because you have not correctly installed JDK, or you have forgotten to modify the JDK path (in autoexec.bat in Windows, and the environment variables in Linux)

3.3 The compiler gives this message when compiling: "Note: Marquesina.java uses a deprecated API". Is there a solution to this?

R: This message is not an error. The compiler is informing you that there is a function in the code that belongs to previous versions of JDK, and that the program will still work, although there are better or faster ways of carrying out this particular task. There is the danger that these functions will disappear in future versions, and that the code won't work with new versions of the virtual machine.

3.4 The compiler says I have not defined a class, but I have finished writing all the code. What am I doing wrong?

R: This can happen when a class is inherited. There are classes that define methods that are not implemented within the class, but need implementing in the classes that inherit them. These methods must be defined even if they are not needed.



printer friendly version