Java With Eclipse: Jaa T C Pse Setup and Getting STTD Started
Java With Eclipse: Jaa T C Pse Setup and Getting STTD Started
Ja a with
Java t Eclipse:
c pse
Setup and Getting
St t d
Started
Customized Java EE Training: http://courses.coreservlets.com/
Servlets, JSP, JSF 2.0, Struts, Ajax, GWT 2.0, Spring, Hibernate, SOAP & RESTful Web Services, Java 6.
Developed and taught by well-known author and developer. At public venues or onsite at your location.
Installing Java
Installing Eclipse
Running Eclipse
• Double click eclipse.exe
– From installDir/bin
• Click on “Workbench” icon
–N
Next time
i you bbring
i up Eclipse,
E li it
i will
ill come up in
i
workbench automaticallly
• Shortcut
– Many developers make shortcut to Eclipse on their
desktop
• R-click eclipse.exe, Copy, then go to desktop, R-click, and
Paste Shortcut
Eclipse: Running Programs
• Executing program from existing project
– Open existing
project
– Double click
Java file to
bring it up in editor
– R-click
li k anywhere
h
in code
– Select Run As
Java Application
– Output goes in
C
Consolel att bottom
b tt
• Note: Class must
have a “main” method
Simple Examples
• Notes
– “A
“Application”
li i ” isi lingo
li for
f a stand-alone
d l Java program
– An application is a Java class that contains “main”
• Most Java classes do not contain “main”,
main , but only those
that do can be directly executed
Executing HelloWorld
• In Eclipse
– Compiling
• Done automatically whenever you save a file
– Executingg
• R-click inside window, then Run As Java Application
– Output (see “Console” tab at bottom)
• Hello,
Hello World
• Manually
– Compiling
p g
• javac HelloWorld.java
– Executing
• java HelloWorld
– Output
• Hello, World
Command-line Arguments
• Useful for learning and testing
– Command-line args are useful for practice
– But, programs given to end users should never use
command-line arguments
• They should pop up a GUI to collect input.
• Eclipse has poor support
– Entering command-line args via Eclipse is more trouble
than it is worth
– So,
So to test with command-line
command line args:
• Save the file in Eclipse (causing it to be compiled)
• Navigate to folder on desktop (not within Eclipse)
• Open command window (Run cmd)
• Type “java Classname arg1 arg2 …”
<BODY>
<H1>HelloWWW: Simple Applet Test.</H1>
</BODY>
</HTML>
Wrap-Up
Q
Questions?
ti ?
Customized Java EE Training: http://courses.coreservlets.com/
Servlets, JSP, JSF 2.0, Struts, Ajax, GWT 2.0, Spring, Hibernate, SOAP & RESTful Web Services, Java 6.
Developed and taught by well-known author and developer. At public venues or onsite at your location.