Presentation is loading. Please wait.

Presentation is loading. Please wait.

UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 1 IT1202-Fundamentals Of Programming (Using JAVA) Interacting with.

Similar presentations


Presentation on theme: "UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 1 IT1202-Fundamentals Of Programming (Using JAVA) Interacting with."— Presentation transcript:

1 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 1 IT1202-Fundamentals Of Programming (Using JAVA) Interacting with Java Programs Version 1.0

2 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 2 Introduction to Java Development Kit (JDK) JDK provides core set of tools that are necessary to develop Professional Java applications These tools are discussed in detail later JDK tools are also written in Java. BIT

3 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 3 BIT Introduction………… JDK is a set of command-line programs, text-based utilities that don’t make use of a graphical user interface. Programmers run each of the JDK’s utilities by typing java GetFunky.class This command tells the java program – the bytecode interpreter – to run a bytecode file called GetFunky.class (As you see later today, compiled Java programs all have the.class file extension)

4 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 4 Introduction………… Windows 95 users must use the MS-DOS prompt command to open a window where commands can be typed.

5 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 5 Introduction………. Installing the Java Development Kit JDK for different platforms available in a CD or can download from the web site: http://java.sun.comhttp://java.sun.com Windows Installation Before installing the JDK on your system make sure that no other Java development tools are installed.

6 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 6 Installation………. To install the JDK on Windows, double-click the installation archive file or use the Start Run command from the Windows taskbar to find and run the file. After you see a dialog box asking whether you want to install JDK the JDK Setup Wizard is displayed. You can use this window to configure how the JDK is installed in your system. The default settings for this wizard should be fine for most users. The JDK is installed in a new folder with a name based on the version you’re downloading (such as \jdk1.2), unless you use the Browse button to select a different folder on your system.

7 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 7 Installation……… The wizard will install the following JDK components: Program files Native Interface header files Tooldocs Demo files

8 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 8 Installation………. Solaris Installation Sun’s Solaris version of the JDK can be installed on the following platforms: SPARC systems running Solaris 2.4 or higher x86 systems running Solaris 2.5 or higher

9 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 9 Creating a source file Java applications are standalone Java programs that do not require a Web browser to run. Run them locally with your mouse or by typing the program name at a command line.

10 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 10 Creating a source file Any plain text editor or text editor capable of saving in ASCII format can be used to create a Source file Examples are DOS EDIT, Notepad etc. Source File should be saved with a.java extension

11 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 11 Creating………. If you are using Windows 95, 98 or NT, a text editor such as Notepad may add an extra.txt file extension to the filename of any Java source files you save. The Java compiler will only handle source files with the.java file extension. To avoid this problem place quotation marks around the filename when you are saving a source file.

12 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 12 Creating……….

13 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 13 Creating…………. Writing the program Choose the editor according to your choice & enter the Java program. class HelloDan { public static void main (String[] arguments) { System.out.println (“What’s your name?”); } } »After finish typing the program, save the file somewhere on your drive with the name HelloDan.java.

14 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 14 Compiling & running the source file Compile the Source File First set the Java Environment Setting The Path In your Autoexec.bat file set the PATH and CLASS PATH as follows PATH …………;\C:\JDK1.3\BIN\…. Indicates any existing paths SET CLASSPATH =C:\JDK1.3\lib\classes.zip;.; BIT

15 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 15 Compiling…………. Compiling and Running the Source File contd.. Assuming you saved your source file in myJavaPrg Directory C:\myJavaPrg>Javac Test.java Java Compiler Source File Name (ensure to use Same name as the class Name) Java Compiler will create a Java byte code file BIT

16 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 16 Running Java Programs To execute byte code file C:\myJavaPrg>Java Test Java Interpreter Class Name Java Byte Code Interpreter Execute the Java Byte code class file BIT

17 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 17 Java byte code file Bytecode is the Java virtual machine’s version of the machine code, the instructions it directly understands. The virtual machine known as Java interpreter or Java runtime.

18 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 18 Java………. The virtual machine takes compiled Java programs & converts their instructions into commands, which known as byte code, can run on any platform & operating system that has a Java virtual machine.

19 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 19 Java byte code interpreter Java code Java Compiler Java Bytecode (Platform Independent) Java Interpreter (Pentium) Java Interpreter (PowerPC)

20 UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 20 Java byte code Interpreter….. Source code, is the set of programming statements a programmer enters into a text editor when creating a program. Source code is compiled into bytecode so that it can be run by a Java virtual machine. The capability of a single bytecode file to run across platforms is crucial to what makes Java work on the World Wide Web, because the Web itself is platform-independent.


Download ppt "UCSC 2003. All rights reserved. No part of this material may be reproduced and sold. 1 IT1202-Fundamentals Of Programming (Using JAVA) Interacting with."

Similar presentations


Ads by Google