160 likes | 364 Views
Preliminaries. CS 310: Object-oriented Programming. Java API. Course Focus. Object-oriented Software Development Problem Solving Techniques Object-oriented Programming Concepts Classes and Objects Encapsulation Inheritance Polymorphism GUI and Applets Java Programming Language.
E N D
Preliminaries CS 310: Object-oriented Programming Java API
Course Focus • Object-oriented Software Development • Problem Solving Techniques • Object-oriented Programming Concepts • Classes and Objects • Encapsulation • Inheritance • Polymorphism • GUI and Applets • Java Programming Language
Tools You Will Need • Tools required for this class. • Computer with an Internet connection • Java SDK (J2SE v. 1.5) • Email account • USB drive (thumb drive)
Java SDK (Software Dev. Kit) • Available free from Sun Mycrosystems • http://java.sun.com/j2se/1.5.2/download.html • Download J2SE v. 1.5 SDK (v. 1.6 is also OK) • How to install Java SDK • http://www.rkmaruyama.net/class/310/howto/310howto.html
jGRASP IDE • JGRASP—an integrated development environment, which allows you to edit source code, compile, and run the program. • Available free from jGRASP(click “download” in left column) • Need to have Java SDK installed first
Testing SDK • Create Folder • Each java project should be in separate folder • C:\310\practice\test\ • Use text editor or Java IDE to write source code • Java source code file has extension .java • File name is case-sensitive.
JCreator IDE • JCreator—an integrated development environment, which allows you to edit source code, compile, and run the program. • Available free from XINOXhttp://www.jcreator.com/ • Need to have Java SDK installed first • How to install JCreatorhttp://www.rkmaruyama.net/class/310/310howto
Java Virtual Machine Text Editor Compiler JVM Source Code Bytecode Output
Sample Source Code • Write the following code exactly, and save it as HelloTest.java. class HelloTest{ public static void main(String[] args){ System.out.print("Hello, world.”); } )
Compile Source Code • Assume: • JDK is installed in D:\jdk15 • Set path--To make JDK compiler visible in any folder • Set path D:\jdk15\bin • Check path • C:\> path -- DOS command • D:\jdk15\bin -- path
Create Byte Code Compile the source code to create a byte code, as follows. D:\310\hello> javac HelloTest.java If there are syntax errors, correct the source code and recompile. The result of a successful compilation is a byte code file named HelloTest.class.
Run Program • Run the program as follows: • D:310\hello> java HelloTest
Useful DOS Commands • C:\> cd 310 -- Go down one level to 310 folder • C:\310> cd ..-- Go up one level, to C:\> • C:\310> D:-- Change to drive DC:\310\> dir -- List all files in the folder • C:\310\> del fileName.ext -- Delete fileName.ext • C:\310\> md aFolder -- Create aFolder • C:\310\> rd oldFolder -- Delete oldFolder
JAR Files • JAR Files—Java Archive files • To package several files into one file • To compress them • For easier transmission over the Internet
JAR Files (cont.) • Syntaxjar {options} jar-file-name file1 file2 file3 • Assume: Mypro.java, Mypro.class, Show.html exist in current folder.jar cf rkm.jar Mypro.jar Mypro.class show.htm • For more details refer toHowTo Create Jar.http://www.rkmaruyama.net/class/310/310howto