SlideShare a Scribd company logo
1 of 22
info@quontrasolutions.co.uk 
Introduction To Core Java 
Quontra solutions 
www.quontrasolutions.co.uk Call : 20-3734-1498
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
What Java is 
• Java is an “easy” programming language, 
– just a tool like C++, VB, …and English. Somehow a 
language tool itself is not so complex. 
• Java works for internet project(mainly), and apply 
“3-tired architecture”, coding on the server-side 
– So besides Java language knowledge, we need to learn 
lots of thing about telecommunication on WEB, to 
finish a real-time project.
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
What Java is(continue) 
• Java applies Object-Oriented Tech. 
– Java is not so difficulty, though OOP is. A java 
expert must be an OOP expert. 
• Java is slower than C++ ( 3-5 times), Java’s 
database function is slower than VB. 
• Java is very portable: cross-platform
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Java’s Features 
• Simple 
Java omits many rarely used, poorly understood, confusing 
features of C++. Say : No Pointer! No dynamic delete. 
• Object Oriented 
Object –oriented design is a technology that focuses design 
on the data (object) and on the interfaces to it. 
Let’s say, everything is an object, everything will 
become a class in Java. Every java program, in top-level 
view, is classes.
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Java’s Features(continue) 
• Distributed 
Basically, Java is for Net-Work application, for WEB 
project. 
Java can open and access “objects” across the Net via 
URLs (Uniform Resource Locator)----eg. 
“http//:gamut.neiu.edu/~ylei/home.html”, 
with the same ease as when accessing a local file system
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Java’s Features(continue) 
• Robust 
The single biggest difference between Java 
and C/C++ is that Java has “a inner safe 
pointer-model”, therefore it eliminates the 
possibility of overwriting memory and corrupting 
data, so programmers feel very safe in coding.
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Java’s Features(continue) 
• GUI [Java-Swing] 
For some reason, Sun believe their java-swing 
is very important, so they always put it in their 
certificate-tests. 
• Multi-threaded 
• Secure [ Exception handling ] 
• Dynamic [ for Server-side coding]
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Java’s cross-platform 
• Interpreted Execute: cross-platform 
why: For cross-platform purpose. Once coding, run anywhere. 
The Java interpreter ( java.exe and its javaVirtualMachine) can 
execute compiled Java-byte-codes(Xxx.class) directly on any machine to 
which the interpreter has been ported. 
How: ( eg. Dos command line style) 
- Edit source code “demo.java” , by notepad/or other IDE tools 
- Compile ( javac.exe ) “demo.java” javac Demo.java  Java byte 
codes, namely, Demo.class 
- Execute (Interpreted Execute) java Demo 
• Speed issue AND new solutions: java is slower than c++ in running. 
however, by now, there are some new technology of Java compiler, such 
as “Just-in-time”, and “HotSpot adaptive Compiler”. They make java 
very faster than before.
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Ps: Compiler and Interpreters: Run in Physical CPU 
1. Compilers use the traditional compile/link/run strategy. 
Examples: C, C++, ML. 
source [complie] native-files [link] nativeprogram [run] 
demo.c --- obj - demo.exe --Intel cpu 
Demoh.h 
2. Interpreters execute the source code directly. Examples: 
BASIC, Perl, TCL/Tk, ML. 
source [load] [interpret run] 
demo.perl - source-program  - Intel cpu 
data
Java: Run in Virtual Cpu 
:cross-platfrom 
Demo.java Compile Demo.class link xxx.class 
Source-code “javac” byte-code files bytecode program 
interpretedly run on VM |-- Intel CPU 
(virtual CPU: JSDK ) |-- … CPU 
|-- Apple CPU 
www.quontrasolutions.co.uk info@quontrasolutions.co.uk
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
How many kinds of Java Programs? 
• Un-network app.: (1)Standalone Java program (today) 
• Network app: non-standalone Java program 
Internet: (2)Applet , (today) 
(3)servlet 
(4)JavaBean classes 
Intranet: (5)EJB ( EnterpriseJavaBean ), 
(6)RMI, etc
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Standalone Java Program 
• The main() method 
public static void main(String args[]){ 
... 
} 
public--- the interpreter can call it 
static ----It is a static method belonging to the class 
void -----It does not return a value 
String----It always has an array of String objects as its formal parameter. 
the array contains any arguments passed to the program on the 
command line 
the source file’s name must match the class name which main method is in
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Java program 
1 // Fig. 2.1: Welcome1.java 
2 // A first program in Java 
3 
4 public class Welcome1 { 
5 public static void main( String args[] ) 
6 { 
7 System.out.println( "Welcome to Java Programming!" ); 
8 } 
9 } 
Welcome to Java Programming!
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
1 // Fig. 2.1: Welcome1.java 
2 // A first program in Java 
3 
4 public class Welcome1 { 
5 public static void main( String args[] ) 
6 { 
7 System.out.println( "Welcome to Java Programming!" ); 
8 } 
9 } 
Program Output
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
A Simple GUI Program: Printing a 
Line of Text 
• Display 
– Most Java applications use windows or a dialog box 
• We have used command window 
– Class JOptionPane allows us to use dialog boxes 
• Packages 
– Set of predefined classes for us to use 
– Groups of related classes called packages 
• Group of all packages known as Java class library or Java 
applications programming interface (Java API) 
– JOptionPane is in the javax.swing package 
• Package has classes for using Graphical User Interfaces (GUIs)
1 // Fig. 2.6: Welcome4.java 
2 // Printing multiple lines in a dialog box 
3 import javax.swing.JOptionPane; // import class JOptionPane 
4 
5 public class Welcome4 { 
6 public static void main( String args[] ) 
7 { 
8 JOptionPane.showMessageDialog( 
9 null, "WelcomentonJavanProgramming!" ); 
10 
11 System.exit( 0 ); // terminate the program 
12 } 
13 } 
www.quontrasolutions.co.uk info@quontrasolutions.co.uk
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Packages 
• Like “namespace” in C++ 
• How to use: 
– C++: using namespace xxx 
– Java: import xxx, or 
import xxx.xx
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
A Simple Java Applet: Drawing a 
1 <html> 
2 <applet code="WelcomeApplet.String 
class" width=300 height=30> 
3 </applet> 
4 </html> 
– appletviewer only understands 
<applet> tags 
• Ignores everything else 
• Minimal browser 
– Executing the applet 
•appletviewer WelcomeApplet.html 
• Perform in directory containing .class file
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
1 // Fig. 3.6: WelcomeApplet.java 
2 // A first applet in Java 
3 import javax.swing.JApplet; // import class JApplet 
4 import java.awt.Graphics; // import class Graphics 
5 
6 public class WelcomeApplet extends JApplet { 
7 public void paint( Graphics g ) 
8 { 
9 g.drawString( "Welcome to Java Programming!", 25, 25 ); 
10 } 
11 } 
1 <html> 
2 <applet code="WelcomeApplet.class" width=300 height=30> 
3 </applet> 
4 </html> 
import allows us to use 
predefined classes (allowing 
us to use applets and 
graphics, in this case). 
extends allows us to inherit the 
capabilities of class JApplet. 
Method paint is guaranteed to 
be called in all applets. Its first 
line must be defined as above.
1 // Fig. 3.8: WelcomeApplet2.java 
2 // Displaying multiple strings 
3 import javax.swing.JApplet; // import class JApplet 
4 import java.awt.Graphics; // import class Graphics 
5 
6 public class WelcomeApplet2 extends JApplet { 
7 public void paint( Graphics g ) 
8 { 
9 g.drawString( "Welcome to", 25, 25 ); 
10 g.drawString( "Java Programming!", 25, 40 ); 
11 } 
12 } 
The two drawString statements 
simulate a newline. In fact, the 
concept of lines of text does not 
exist when drawing strings. 
1 <html> 
2 <applet code="WelcomeApplet2.class" width=300 height=45> 
3 </applet> 
4 </html> 
www.quontrasolutions.co.uk info@quontrasolutions.co.uk
1 // Displaying text and lines 
2 import javax.swing.JApplet; // import class JApplet 
3 import java.awt.Graphics; // import class Graphics 
4 
5 public class WelcomeLines extends JApplet { 
6 public void paint( Graphics g ) 
7 { 
8 g.drawLine( 15, 10, 210, 10 ); 
9 g.drawLine( 15, 30, 210, 30 ); 
10 g.drawString( "Welcome to Java Programming!", 25, 25 ); 
11 } 
12 } 
Draw horizontal lines with 
drawLine (endpoints have same 
y coordinate). 
1 <html> 
2 <applet code="WelcomeLines.class" width=300 height=40> 
3 </applet> 
4 </html> 
www.quontrasolutions.co.uk info@quontrasolutions.co.uk
www.quontrasolutions.co.uk 
info@quontrasolutions.co.uk 
Visit: http://www.quontrasolutions.co.uk/ 
Email: info@quontrasolutions.co.uk 
Call Now : 
US: +1 (404)-900-9988. 
UK: (20)-3734-1498.

More Related Content

What's hot

Advance java prasentation
Advance java prasentationAdvance java prasentation
Advance java prasentationdhananajay95
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1sotlsoc
 
01. Introduction to programming with java
01. Introduction to programming with java01. Introduction to programming with java
01. Introduction to programming with javaIntro C# Book
 
Great cup of java
Great  cup of javaGreat  cup of java
Great cup of javaCIB Egypt
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Mr. Akaash
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javajayc8586
 
Presentation - Course about JavaFX
Presentation - Course about JavaFXPresentation - Course about JavaFX
Presentation - Course about JavaFXTom Mix Petreca
 

What's hot (17)

Advance java prasentation
Advance java prasentationAdvance java prasentation
Advance java prasentation
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
Introduction to java programming part 1
Introduction to java programming   part 1Introduction to java programming   part 1
Introduction to java programming part 1
 
Basic java part_ii
Basic java part_iiBasic java part_ii
Basic java part_ii
 
01. Introduction to programming with java
01. Introduction to programming with java01. Introduction to programming with java
01. Introduction to programming with java
 
Java Notes
Java Notes Java Notes
Java Notes
 
Great cup of java
Great  cup of javaGreat  cup of java
Great cup of java
 
Java notes
Java notesJava notes
Java notes
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
 
Java &amp; advanced java
Java &amp; advanced javaJava &amp; advanced java
Java &amp; advanced java
 
1.introduction to java
1.introduction to java1.introduction to java
1.introduction to java
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Presentation - Course about JavaFX
Presentation - Course about JavaFXPresentation - Course about JavaFX
Presentation - Course about JavaFX
 
1- java
1- java1- java
1- java
 
Java features
Java featuresJava features
Java features
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 

Viewers also liked

Harian Pelita 2012 07 27 Hal 04
Harian Pelita 2012 07 27 Hal 04Harian Pelita 2012 07 27 Hal 04
Harian Pelita 2012 07 27 Hal 04Taruna Ikrar
 
Phantom alertcomplaint
Phantom alertcomplaintPhantom alertcomplaint
Phantom alertcomplaintGreg Sterling
 
Career Services for undergrad research
Career Services for undergrad researchCareer Services for undergrad research
Career Services for undergrad researchArun Noranarith
 
Living simply BY JOSH CAISTOR
Living simply BY JOSH CAISTORLiving simply BY JOSH CAISTOR
Living simply BY JOSH CAISTORjoshuacaistor11
 
BALASAINMA_RESUME
BALASAINMA_RESUMEBALASAINMA_RESUME
BALASAINMA_RESUMER Every
 
Head First Java Chapter 3
Head First Java Chapter 3Head First Java Chapter 3
Head First Java Chapter 3Tom Henricksen
 
Pit1 diagnosis dan-tatalaksana-dbd-terkini
Pit1 diagnosis dan-tatalaksana-dbd-terkiniPit1 diagnosis dan-tatalaksana-dbd-terkini
Pit1 diagnosis dan-tatalaksana-dbd-terkinierma permata
 
Enanitos mentales capítulo 8
Enanitos mentales capítulo 8Enanitos mentales capítulo 8
Enanitos mentales capítulo 8Yeral Palacĭo
 
Tatalaksana gangguan cemas
Tatalaksana gangguan cemasTatalaksana gangguan cemas
Tatalaksana gangguan cemasSuharti Wairagya
 
Sociedad en comandita simple
Sociedad en comandita simpleSociedad en comandita simple
Sociedad en comandita simpleFausto Pantoja
 

Viewers also liked (12)

Harian Pelita 2012 07 27 Hal 04
Harian Pelita 2012 07 27 Hal 04Harian Pelita 2012 07 27 Hal 04
Harian Pelita 2012 07 27 Hal 04
 
Phantom alertcomplaint
Phantom alertcomplaintPhantom alertcomplaint
Phantom alertcomplaint
 
Thesis
ThesisThesis
Thesis
 
Career Services for undergrad research
Career Services for undergrad researchCareer Services for undergrad research
Career Services for undergrad research
 
Installs
InstallsInstalls
Installs
 
Living simply BY JOSH CAISTOR
Living simply BY JOSH CAISTORLiving simply BY JOSH CAISTOR
Living simply BY JOSH CAISTOR
 
BALASAINMA_RESUME
BALASAINMA_RESUMEBALASAINMA_RESUME
BALASAINMA_RESUME
 
Head First Java Chapter 3
Head First Java Chapter 3Head First Java Chapter 3
Head First Java Chapter 3
 
Pit1 diagnosis dan-tatalaksana-dbd-terkini
Pit1 diagnosis dan-tatalaksana-dbd-terkiniPit1 diagnosis dan-tatalaksana-dbd-terkini
Pit1 diagnosis dan-tatalaksana-dbd-terkini
 
Enanitos mentales capítulo 8
Enanitos mentales capítulo 8Enanitos mentales capítulo 8
Enanitos mentales capítulo 8
 
Tatalaksana gangguan cemas
Tatalaksana gangguan cemasTatalaksana gangguan cemas
Tatalaksana gangguan cemas
 
Sociedad en comandita simple
Sociedad en comandita simpleSociedad en comandita simple
Sociedad en comandita simple
 

Similar to Introduction to Core Java Concepts

Similar to Introduction to Core Java Concepts (20)

Javalecture 1
Javalecture 1Javalecture 1
Javalecture 1
 
Java1 in mumbai
Java1 in mumbaiJava1 in mumbai
Java1 in mumbai
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
basic_java.ppt
basic_java.pptbasic_java.ppt
basic_java.ppt
 
Java Programming concept
Java Programming concept Java Programming concept
Java Programming concept
 
Letest
LetestLetest
Letest
 
Java programing language unit 1 introduction
Java programing language unit 1 introductionJava programing language unit 1 introduction
Java programing language unit 1 introduction
 
Curso de Programación Java Básico
Curso de Programación Java BásicoCurso de Programación Java Básico
Curso de Programación Java Básico
 
Java introduction
Java introductionJava introduction
Java introduction
 
Java lab-manual
Java lab-manualJava lab-manual
Java lab-manual
 
Java1
Java1Java1
Java1
 
Java1
Java1Java1
Java1
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBC
 
Introduction to Java Programming.pdf
Introduction to Java Programming.pdfIntroduction to Java Programming.pdf
Introduction to Java Programming.pdf
 
oop unit1.pptx
oop unit1.pptxoop unit1.pptx
oop unit1.pptx
 

More from QUONTRASOLUTIONS

Big data introduction by quontra solutions
Big data introduction by quontra solutionsBig data introduction by quontra solutions
Big data introduction by quontra solutionsQUONTRASOLUTIONS
 
Cognos Online Training with placement Assistance - QuontraSolutions
Cognos Online Training with placement Assistance - QuontraSolutionsCognos Online Training with placement Assistance - QuontraSolutions
Cognos Online Training with placement Assistance - QuontraSolutionsQUONTRASOLUTIONS
 
Business analyst overview by quontra solutions
Business analyst overview by quontra solutionsBusiness analyst overview by quontra solutions
Business analyst overview by quontra solutionsQUONTRASOLUTIONS
 
Business analyst overview by quontra solutions
Business analyst overview by quontra solutionsBusiness analyst overview by quontra solutions
Business analyst overview by quontra solutionsQUONTRASOLUTIONS
 
Software Quality Assurance training by QuontraSolutions
Software Quality Assurance training by QuontraSolutionsSoftware Quality Assurance training by QuontraSolutions
Software Quality Assurance training by QuontraSolutionsQUONTRASOLUTIONS
 
Introduction to software quality assurance by QuontraSolutions
Introduction to software quality assurance by QuontraSolutionsIntroduction to software quality assurance by QuontraSolutions
Introduction to software quality assurance by QuontraSolutionsQUONTRASOLUTIONS
 
.Net introduction by Quontra Solutions
.Net introduction by Quontra Solutions.Net introduction by Quontra Solutions
.Net introduction by Quontra SolutionsQUONTRASOLUTIONS
 
Introduction to j2 ee patterns online training class
Introduction to j2 ee patterns online training classIntroduction to j2 ee patterns online training class
Introduction to j2 ee patterns online training classQUONTRASOLUTIONS
 
Saas overview by quontra solutions
Saas overview  by quontra solutionsSaas overview  by quontra solutions
Saas overview by quontra solutionsQUONTRASOLUTIONS
 
Sharepoint taxonomy introduction us
Sharepoint taxonomy introduction   usSharepoint taxonomy introduction   us
Sharepoint taxonomy introduction usQUONTRASOLUTIONS
 
Introduction to the sharepoint 2013 userprofile service By Quontra
Introduction to the sharepoint 2013 userprofile service By QuontraIntroduction to the sharepoint 2013 userprofile service By Quontra
Introduction to the sharepoint 2013 userprofile service By QuontraQUONTRASOLUTIONS
 
Introduction to SharePoint 2013 REST API
Introduction to SharePoint 2013 REST APIIntroduction to SharePoint 2013 REST API
Introduction to SharePoint 2013 REST APIQUONTRASOLUTIONS
 
Performance Testing and OBIEE by QuontraSolutions
Performance Testing and OBIEE by QuontraSolutionsPerformance Testing and OBIEE by QuontraSolutions
Performance Testing and OBIEE by QuontraSolutionsQUONTRASOLUTIONS
 
Obiee introduction building reports by QuontraSolutions
Obiee introduction building reports by QuontraSolutionsObiee introduction building reports by QuontraSolutions
Obiee introduction building reports by QuontraSolutionsQUONTRASOLUTIONS
 
Sharepoint designer workflow by quontra us
Sharepoint designer workflow by quontra usSharepoint designer workflow by quontra us
Sharepoint designer workflow by quontra usQUONTRASOLUTIONS
 

More from QUONTRASOLUTIONS (20)

Big data introduction by quontra solutions
Big data introduction by quontra solutionsBig data introduction by quontra solutions
Big data introduction by quontra solutions
 
Java constructors
Java constructorsJava constructors
Java constructors
 
Cognos Online Training with placement Assistance - QuontraSolutions
Cognos Online Training with placement Assistance - QuontraSolutionsCognos Online Training with placement Assistance - QuontraSolutions
Cognos Online Training with placement Assistance - QuontraSolutions
 
Business analyst overview by quontra solutions
Business analyst overview by quontra solutionsBusiness analyst overview by quontra solutions
Business analyst overview by quontra solutions
 
Business analyst overview by quontra solutions
Business analyst overview by quontra solutionsBusiness analyst overview by quontra solutions
Business analyst overview by quontra solutions
 
Cognos Overview
Cognos Overview Cognos Overview
Cognos Overview
 
Hibernate online training
Hibernate online trainingHibernate online training
Hibernate online training
 
Java j2eeTutorial
Java j2eeTutorialJava j2eeTutorial
Java j2eeTutorial
 
Software Quality Assurance training by QuontraSolutions
Software Quality Assurance training by QuontraSolutionsSoftware Quality Assurance training by QuontraSolutions
Software Quality Assurance training by QuontraSolutions
 
Introduction to software quality assurance by QuontraSolutions
Introduction to software quality assurance by QuontraSolutionsIntroduction to software quality assurance by QuontraSolutions
Introduction to software quality assurance by QuontraSolutions
 
.Net introduction by Quontra Solutions
.Net introduction by Quontra Solutions.Net introduction by Quontra Solutions
.Net introduction by Quontra Solutions
 
Introduction to j2 ee patterns online training class
Introduction to j2 ee patterns online training classIntroduction to j2 ee patterns online training class
Introduction to j2 ee patterns online training class
 
Saas overview by quontra solutions
Saas overview  by quontra solutionsSaas overview  by quontra solutions
Saas overview by quontra solutions
 
Sharepoint taxonomy introduction us
Sharepoint taxonomy introduction   usSharepoint taxonomy introduction   us
Sharepoint taxonomy introduction us
 
Introduction to the sharepoint 2013 userprofile service By Quontra
Introduction to the sharepoint 2013 userprofile service By QuontraIntroduction to the sharepoint 2013 userprofile service By Quontra
Introduction to the sharepoint 2013 userprofile service By Quontra
 
Introduction to SharePoint 2013 REST API
Introduction to SharePoint 2013 REST APIIntroduction to SharePoint 2013 REST API
Introduction to SharePoint 2013 REST API
 
Performance Testing and OBIEE by QuontraSolutions
Performance Testing and OBIEE by QuontraSolutionsPerformance Testing and OBIEE by QuontraSolutions
Performance Testing and OBIEE by QuontraSolutions
 
Obiee introduction building reports by QuontraSolutions
Obiee introduction building reports by QuontraSolutionsObiee introduction building reports by QuontraSolutions
Obiee introduction building reports by QuontraSolutions
 
Sharepoint designer workflow by quontra us
Sharepoint designer workflow by quontra usSharepoint designer workflow by quontra us
Sharepoint designer workflow by quontra us
 
Qa by quontra us
Qa by quontra   usQa by quontra   us
Qa by quontra us
 

Introduction to Core Java Concepts

  • 1. info@quontrasolutions.co.uk Introduction To Core Java Quontra solutions www.quontrasolutions.co.uk Call : 20-3734-1498
  • 2. www.quontrasolutions.co.uk info@quontrasolutions.co.uk What Java is • Java is an “easy” programming language, – just a tool like C++, VB, …and English. Somehow a language tool itself is not so complex. • Java works for internet project(mainly), and apply “3-tired architecture”, coding on the server-side – So besides Java language knowledge, we need to learn lots of thing about telecommunication on WEB, to finish a real-time project.
  • 3. www.quontrasolutions.co.uk info@quontrasolutions.co.uk What Java is(continue) • Java applies Object-Oriented Tech. – Java is not so difficulty, though OOP is. A java expert must be an OOP expert. • Java is slower than C++ ( 3-5 times), Java’s database function is slower than VB. • Java is very portable: cross-platform
  • 4. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Java’s Features • Simple Java omits many rarely used, poorly understood, confusing features of C++. Say : No Pointer! No dynamic delete. • Object Oriented Object –oriented design is a technology that focuses design on the data (object) and on the interfaces to it. Let’s say, everything is an object, everything will become a class in Java. Every java program, in top-level view, is classes.
  • 5. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Java’s Features(continue) • Distributed Basically, Java is for Net-Work application, for WEB project. Java can open and access “objects” across the Net via URLs (Uniform Resource Locator)----eg. “http//:gamut.neiu.edu/~ylei/home.html”, with the same ease as when accessing a local file system
  • 6. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Java’s Features(continue) • Robust The single biggest difference between Java and C/C++ is that Java has “a inner safe pointer-model”, therefore it eliminates the possibility of overwriting memory and corrupting data, so programmers feel very safe in coding.
  • 7. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Java’s Features(continue) • GUI [Java-Swing] For some reason, Sun believe their java-swing is very important, so they always put it in their certificate-tests. • Multi-threaded • Secure [ Exception handling ] • Dynamic [ for Server-side coding]
  • 8. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Java’s cross-platform • Interpreted Execute: cross-platform why: For cross-platform purpose. Once coding, run anywhere. The Java interpreter ( java.exe and its javaVirtualMachine) can execute compiled Java-byte-codes(Xxx.class) directly on any machine to which the interpreter has been ported. How: ( eg. Dos command line style) - Edit source code “demo.java” , by notepad/or other IDE tools - Compile ( javac.exe ) “demo.java” javac Demo.java  Java byte codes, namely, Demo.class - Execute (Interpreted Execute) java Demo • Speed issue AND new solutions: java is slower than c++ in running. however, by now, there are some new technology of Java compiler, such as “Just-in-time”, and “HotSpot adaptive Compiler”. They make java very faster than before.
  • 9. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Ps: Compiler and Interpreters: Run in Physical CPU 1. Compilers use the traditional compile/link/run strategy. Examples: C, C++, ML. source [complie] native-files [link] nativeprogram [run] demo.c --- obj - demo.exe --Intel cpu Demoh.h 2. Interpreters execute the source code directly. Examples: BASIC, Perl, TCL/Tk, ML. source [load] [interpret run] demo.perl - source-program  - Intel cpu data
  • 10. Java: Run in Virtual Cpu :cross-platfrom Demo.java Compile Demo.class link xxx.class Source-code “javac” byte-code files bytecode program interpretedly run on VM |-- Intel CPU (virtual CPU: JSDK ) |-- … CPU |-- Apple CPU www.quontrasolutions.co.uk info@quontrasolutions.co.uk
  • 11. www.quontrasolutions.co.uk info@quontrasolutions.co.uk How many kinds of Java Programs? • Un-network app.: (1)Standalone Java program (today) • Network app: non-standalone Java program Internet: (2)Applet , (today) (3)servlet (4)JavaBean classes Intranet: (5)EJB ( EnterpriseJavaBean ), (6)RMI, etc
  • 12. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Standalone Java Program • The main() method public static void main(String args[]){ ... } public--- the interpreter can call it static ----It is a static method belonging to the class void -----It does not return a value String----It always has an array of String objects as its formal parameter. the array contains any arguments passed to the program on the command line the source file’s name must match the class name which main method is in
  • 13. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Java program 1 // Fig. 2.1: Welcome1.java 2 // A first program in Java 3 4 public class Welcome1 { 5 public static void main( String args[] ) 6 { 7 System.out.println( "Welcome to Java Programming!" ); 8 } 9 } Welcome to Java Programming!
  • 14. www.quontrasolutions.co.uk info@quontrasolutions.co.uk 1 // Fig. 2.1: Welcome1.java 2 // A first program in Java 3 4 public class Welcome1 { 5 public static void main( String args[] ) 6 { 7 System.out.println( "Welcome to Java Programming!" ); 8 } 9 } Program Output
  • 15. www.quontrasolutions.co.uk info@quontrasolutions.co.uk A Simple GUI Program: Printing a Line of Text • Display – Most Java applications use windows or a dialog box • We have used command window – Class JOptionPane allows us to use dialog boxes • Packages – Set of predefined classes for us to use – Groups of related classes called packages • Group of all packages known as Java class library or Java applications programming interface (Java API) – JOptionPane is in the javax.swing package • Package has classes for using Graphical User Interfaces (GUIs)
  • 16. 1 // Fig. 2.6: Welcome4.java 2 // Printing multiple lines in a dialog box 3 import javax.swing.JOptionPane; // import class JOptionPane 4 5 public class Welcome4 { 6 public static void main( String args[] ) 7 { 8 JOptionPane.showMessageDialog( 9 null, "WelcomentonJavanProgramming!" ); 10 11 System.exit( 0 ); // terminate the program 12 } 13 } www.quontrasolutions.co.uk info@quontrasolutions.co.uk
  • 17. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Packages • Like “namespace” in C++ • How to use: – C++: using namespace xxx – Java: import xxx, or import xxx.xx
  • 18. www.quontrasolutions.co.uk info@quontrasolutions.co.uk A Simple Java Applet: Drawing a 1 <html> 2 <applet code="WelcomeApplet.String class" width=300 height=30> 3 </applet> 4 </html> – appletviewer only understands <applet> tags • Ignores everything else • Minimal browser – Executing the applet •appletviewer WelcomeApplet.html • Perform in directory containing .class file
  • 19. www.quontrasolutions.co.uk info@quontrasolutions.co.uk 1 // Fig. 3.6: WelcomeApplet.java 2 // A first applet in Java 3 import javax.swing.JApplet; // import class JApplet 4 import java.awt.Graphics; // import class Graphics 5 6 public class WelcomeApplet extends JApplet { 7 public void paint( Graphics g ) 8 { 9 g.drawString( "Welcome to Java Programming!", 25, 25 ); 10 } 11 } 1 <html> 2 <applet code="WelcomeApplet.class" width=300 height=30> 3 </applet> 4 </html> import allows us to use predefined classes (allowing us to use applets and graphics, in this case). extends allows us to inherit the capabilities of class JApplet. Method paint is guaranteed to be called in all applets. Its first line must be defined as above.
  • 20. 1 // Fig. 3.8: WelcomeApplet2.java 2 // Displaying multiple strings 3 import javax.swing.JApplet; // import class JApplet 4 import java.awt.Graphics; // import class Graphics 5 6 public class WelcomeApplet2 extends JApplet { 7 public void paint( Graphics g ) 8 { 9 g.drawString( "Welcome to", 25, 25 ); 10 g.drawString( "Java Programming!", 25, 40 ); 11 } 12 } The two drawString statements simulate a newline. In fact, the concept of lines of text does not exist when drawing strings. 1 <html> 2 <applet code="WelcomeApplet2.class" width=300 height=45> 3 </applet> 4 </html> www.quontrasolutions.co.uk info@quontrasolutions.co.uk
  • 21. 1 // Displaying text and lines 2 import javax.swing.JApplet; // import class JApplet 3 import java.awt.Graphics; // import class Graphics 4 5 public class WelcomeLines extends JApplet { 6 public void paint( Graphics g ) 7 { 8 g.drawLine( 15, 10, 210, 10 ); 9 g.drawLine( 15, 30, 210, 30 ); 10 g.drawString( "Welcome to Java Programming!", 25, 25 ); 11 } 12 } Draw horizontal lines with drawLine (endpoints have same y coordinate). 1 <html> 2 <applet code="WelcomeLines.class" width=300 height=40> 3 </applet> 4 </html> www.quontrasolutions.co.uk info@quontrasolutions.co.uk
  • 22. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Visit: http://www.quontrasolutions.co.uk/ Email: info@quontrasolutions.co.uk Call Now : US: +1 (404)-900-9988. UK: (20)-3734-1498.