![]() |
|
||||||||||||
![]() | |||||||||||||
|
Call Us Toll-Free (877) 256-0328 Outside USA 1 - (201) 505-0430
|
Trail: Getting Started
Lesson: The "Hello World!" Application "Hello World!" for Solaris OS and Linux
Home Page
>
Getting Started
>
The "Hello World!" Application
"Hello World!" for Solaris OS and Linux
A Checklist
|
|
Start the Pico editor
by typing When you start Pico, it'll display a new, blank buffer. This is the area in which you will type your code. |
|
Type the following code into the new buffer:
/**
* The HelloWorldApp class implements an application that
* simply prints "Hello World!" to standard output.
*/
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Display the string.
}
}
Type all code, commands, and file names exactly
as shown. Both the compiler (
|
Save the code in a file with the name
HelloWorldApp.java.
In the Pico editor, you do this
by typing Ctrl-O
and then, at the bottom where you see the prompt File Name to write:,
entering the directory in which you wish to create the file,
followed by HelloWorldApp.java. For example, if you wish to
save HelloWorldApp.java in the directory /home/jdoe/java,
then you type /home/jdoe/java/HelloWorldApp.java
and press Return.
You can type Ctrl-X to exit Pico.
.class FileBring up another shell window. To compile your source file, change your current directory to the directory where your file is located. For example, if your source directory is
/home/jdoe/java, type the following command at the prompt and press Return:cd /home/jdoe/javaIf you enter
pwdat the prompt, you should see the current directory, which in this example has been changed to/home/jdoe/java.If you enter
lsat the prompt, you should see your file.
Results of the
lscommand, showing the.javasource file.Now are ready to compile the source file. At the prompt, type the following command and press Return.
javac HelloWorldApp.javaThe compiler has generated a bytecode file,
HelloWorldApp.class. At the prompt, typelsto see the new file that was generated: the following figure.
Results of the
lscommand, showing the generated.classfile.Now that you have a
.classfile, you can run your program.If you encounter problems with the instructions in this step, consult the Common Problems (and Their Solutions).
In the same directory, enter at the prompt:java HelloWorldAppThe next figure shows what you should now see.
The output prints "Hello World!" to the screen.
Congratulations! Your program works!
If you encounter problems with the instructions in this step, consult the Common Problems (and Their Solutions).
JSP
Servlets
Tomcat
mysql
Java
JSP
Servlets
Tomcat
mysql
Java
JSP
Servlets
Tomcat
mysql
Java
JSP
Servlets
Tomcat
mysql
Java
JSP at JSP.aldenWEBhosting.com
Servlets at servlets.aldenWEBhosting.com
Tomcat at Tomcat.aldenWEBhosting.com
mysql at mysql.aldenWEBhosting.com
Java at Java.aldenWEBhosting.com
Web Hosts Portal
Web Links
Web Links
Web Hosting
JSP Solutions Web Links
JSP Solutions Web Hosting
Servlets Solutions Web Links
Servlets Solutions Web Hosting
Web Links
Web Links
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
jsp hosting
servlets hosting
web hosting
web sites designed
cheap web hosting
web site hosting
myspace web hosting