cancel
Showing results for 
Search instead for 
Did you mean: 

about solaris of jdk

Former Member
0 Kudos

how to config solaris of the java development kit? thanks

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

I think your question is how to configure java development kit on solaris:

JDK to be used:

Sun Solaris SPARC 32 Sun 1.4.2_14

Sun Solaris SPARC 64 Sun 1.4.2_14

Now Command to install JDK

rpm -ivh XXXXXXXXX.rpm

Setup JAVA_HOME and Path

server:/#Vi/root/.profile

In the Vi editor ,mention the below paths and save

export JAVA_HOME=/path of jdk

export PATH=$PATH:/opt/jdk path

Log off and login to take effect.

Now login as root

Type command:

echo $PATH

Output:path where jdk is installed

Any issues feel free to contact:

Reward maximum points:

praveenkumar_kadi
Active Contributor
0 Kudos

Hi

Sun's JDK for Solaris comes as a .tgz copy it to your home directory and use the following commands

gunzip ./jdk1.1.6.tgz (for ex:)

tar -xvf ./jdk1.1.6.tar

You will end up with a Java directory that contains the full JDK, if you are curious enough you will notice that the java/lib directory contains a classes.zip file - DO NOT UNZIP IT - it needs to in a zipped form for it to work correctly.

Configuring the JDK

With most distributions of JDK chances are that it has been correctly configured for you. Still it is recommended that you check the following:

Solaris: To configure JDK for Solaris all you need to do is add the java/bin or jdk/bin directory to your execution path. Usually a line like this in your .cshrc .login or .profile files will work:

set path = (~/java/bin/ $path)

assuming that your java files are indeed in the directory java.

Log out and log back in for the changes to take effect. Or use:

source ~/.login

Creating a Java Application

Ah! Finally we can get down to work. We will program the ubiquitous Hello World example.

remember we are going to write a Java Application rather than a Java Applet , but don't despair we will talk more about creating Applets in the part II of this article.

Creating the Source file

As with any programming language, the Java source files are created in plain text editor that means you are either working in notepad, wordpad OR emacs, vi or joe depending on your OS even DOS edit will do !

Now type in the following code exactly as below

class HelloWorld{

public static void main(String args[]){

System.out.println("Hello world!");

}

}

Save the file somewhere on your disk with the name HelloWorld.java This is very important. Java source file must have the same name as the class they define (remember the case as well) and they must have the extension .java. If you name the file something else (even helloworld.java) you won't be able to able to compile it.

Once you are there, you can use the Java Compiler, Using the Java compiler is no big deal just use:

javac HelloWorld.java

Again making sure that you type all the upper and lower case properly here as well. If all goes well then you will end up with a class file, (nothing to do with the quality of file called HelloWorld.class. this is your Java bytecode file. If you get any error, just repeat the above carefully again.

Once you have the class file ready, run it using the Java Bytecode Interpreter, another bombastic word! at the command prompt just type:

java HelloWorld

(Note: you don't have to type the extension class after the HelloWorld).

Congrats! if you see the phrase "Hello World" printed on your screen you have just successfully written and executed your first Java Application. The procedure for Linux is no different Use an Xterm window if you are using Xwindows to compile and execute the Java program other wise the Compiler and Interpreter run directly from the command prompt.