cop 3330 notes 1/12. today's topics downloading java and eclipse hello world basic control...

24
COP 3330 Notes 1/12

Upload: rudolf-solomon-johns

Post on 01-Jan-2016

219 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

COP 3330

Notes 1/12

Page 2: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Today's topics

• Downloading Java and Eclipse

• Hello World

• Basic control structures

• Basic I/O

• Strings

Page 3: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Downloading Java

Page 4: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Downloading Java

Page 5: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Downloading Java

Page 6: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Downloading Eclipse

Page 7: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Downloading Eclipse

Page 8: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Creating a Java Program With Eclipse

Page 9: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Creating a Java Program With Eclipse

Page 10: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Creating a Java Program With Eclipse

Page 11: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Creating a Java Program With Eclipse

Page 12: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Creating a Java Program With Eclipse

Page 13: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Running a Java Program With Eclipse

Page 14: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Running a Java Program With Eclipse

• Double-click Java Application

Page 15: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Running a Java Program With Eclipse

Page 16: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Running a Java Program Using Command Line

Page 17: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Running a Java Program Using Command Line

Page 18: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Running a Java Program Using Command Line

Page 19: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Running a Java Program Using Command Line

• Add the path of the bin directory of your JDK install to your path environment variable

• In my case:– C:\Program Files\Java\jdk1.5.0_04\bin

Page 20: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Running a Java Program Using Command Line

Page 21: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Running a Java Program Using Command Line

Page 22: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Running a Java Program Using Command Line

• If you get the error: – Exception in thread "main"

java.lang.NoClassDefFoundError: HelloWorldApp

• Make sure you’re in the same directory as your .java file and that you typed everything correctly

• If you still get the error, type at the command line: set CLASSPATH=

Page 23: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Java Virtual Machine

• Java is compiled to Java bytecode, not machine language

• Java bytecode is similar to machine code except that it is meant for the Java Virtual Machine (JVM)

• The JVM is an interpreter of Java bytecode (i.e. it runs Java programs)

Page 24: COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings

Java Virtual Machine

• Machine language must be specific to a processor, so programs written in most languages must be recompiled to run on different processors

• The same compiled Java program can run on any computer that can run the correct version of the JVM