Compiling and Running a Java Program

Slides:



Advertisements
Similar presentations
Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
Advertisements

CSCI S-1 Section 5. Deadlines for Problem Set 3 Part A – Friday, July 10, 17:00 EST Parts B – Tuesday, July 14, 17:00 EST Getting the code examples from.
Java Programming Working with TextPad. Using TextPad to Work with Java This text editor is designed for working with Java You can download a trial version.
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
Slide 1 of 40. Lecture A The Java Programming Language Invented 1995 by James Gosling at Sun Microsystems. Based on previous languages: C, C++, Objective-C,
Chapter 2: Java Fundamentals Java Program Structure.
Introduction to Java.
SEEM3460 Tutorial Java Programming in Unix. Code Translation Java source code Java bytecode Java compiler Bytecode interpreter machine code for target.
Writing algorithms using the for-statement. Programming example 1: find all divisors of a number We have seen a program using a while-statement to solve.
Computer Programming Lab(4).
From BlueJ to NetBeans SWC 2.semester.
Java Lecture 16: Dolores Zage. WWW n Was a method for distributing passive information n added forms and image maps n interaction was only a new way to.
1 Introduction to Java Brief history of Java Sample Java Program Compiling & Executing Reading: => Section 1.1.
Java TA Session 1. Software Java Runtime Environment (JRE) java.exe Java Development Kit (JDK) java.exe, javac.exe Version 1.6 = Version 6, Version 1.7.
Chapter 5: Preparing Java Programs 1 Chapter 5 Preparing Java Programs.
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
The dangling-else ambiguity. Previously discussed The Java compiler (translator) consider white space characters (i.e., SPACE, TAB and New line) as insignificant.
Boolean expressions, part 2: Logical operators. Previously discussed Recall that there are 2 types of operators that return a boolean result (true or.
Lecture 3 January 14, 2002 CSC Programming I Fall 2001.
Assignment statements using the same variable in LHS and RHS.
CSci 111 – computer Science I Fall 2014 Cynthia Zickos WRITING A SIMPLE PROGRAM IN JAVA.
Programming Fundamentals 2: Simple/ F II Objectives – –give some simple examples of Java applications and one applet 2. Simple Java.
Mixing integer and floating point numbers in an arithmetic operation.
CS-1030 Dr. Mark L. Hornick 1 Java Review Interactive.
Unix Environment Input Output 2  List Content (ls) ◦ ls (list current directory) ◦ ls –all (include hidden files/folders)  Make directory (mkdir) ◦
Chapter 6. else-if & switch Copyright © 2012 Pearson Education, Inc.
More about Java Chapter 2 9/8 & 9/9 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File.
CSI 3125, Preliminaries, page 1 Compiling the Program.
By Mr. Muhammad Pervez Akhtar
Reading input from the console input. Java's console input The console is the terminal window that is running the Java program I.e., that's the terminal.
Introduction to array: why use arrays ?. Motivational example Problem: Write a program that reads in and stores away 5 double numbers After reading in.
Boolean expressions, part 1: Compare operators. Compare operators Compare operators compare 2 numerical values and return a Boolean (logical) value A.
Martin T. Press.  Main Method and Class Name  Printing To Screen  Scanner.
Files Review For output to a file: –FileOutputStream variable initialized to filename (String) and append/not append (boolean) –PrintWriter variable initialized.
Computer Programming Lab 9. Exercise 1 Source Code package excercise1; import java.util.Scanner; public class Excercise1 { public static void main(String[]
import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.
Interactive Programs Programs that get input from the user 1 In PowerPoint, click on the speaker icon then click the "Play" button to hear the narration.
1 Simple Input Interactive Input - The Class Scanner n Command-Line Arguments.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
1 Text File Input and Output. Objectives You will be able to Write text files from your Java programs. Read text files in your Java programs. 2.
2.5 Edit, Compile, and Execute Figure 2-3 illustrates the edit, compile and execute steps. Java bytecode.
Reading Parameters CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D.
Introduction of Java Fikri Fadlillah, S.T.
Java Programming in Unix
TemperatureConversion
Software Development Packages
Maha AlSaif Maryam AlQattan
Programming without BlueJ Week 12
Going from C++ to Java Jayden Navarro.
Comp Sci 200 Programming I Jim Williams, PhD.
Something about Java Introduction to Problem Solving and Programming 1.
An Introduction to Java – Part I, language basics
Introduction to Classes and Methods
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
Subprograms Functions.
Java Intro.
Differences between Java and JavaScript
Introduction to Java Brief history of Java Sample Java Program
Module 3 Selection Structures 4/5/2019 CSE 1321 Module 3.
How Java Program Executes
Developing Java Applications with NetBeans
Chapter 2: Java Fundamentals
Developing Java Applications with NetBeans
CS Week 2 Jim Williams, PhD.
F II 2. Simple Java Programs Objectives
Random Numbers while loop
CS Programming I Jim Williams, PhD.
Compile and run c files.
Presentation transcript:

Compiling and Running a Java Program 1) Compile the program to generate the bytecode (executable -- .class) using javac :     > javac TempConverter.java 2) Interpret (run) the bytecode (executable .class) using the java interpreter:     > java TempConverter Use an editor to type in the new Java program below.  Note that the program name is TempConverter, so, by the naming rules of Java, your file name must be TempConverter.java. The class name must be the same filename.  Start your editor (i.e. pico in UNIX or Notepad on your PC or NetBeans) : Save the file as TempConverter.java  

import java.util.Scanner; public class TempConverter { public static void main (String[] args) final int BASE = 32; final double CONVERSION_FACTOR = 5.0 / 9.0; double celsiusTemp, fahrenheitTemp; Scanner scan = new Scanner(System.in); System.out.print ("Enter a Fahrenheit temperature: "); fahrenheitTemp = scan.nextDouble(); celsiusTemp = CONVERSION_FACTOR * (fahrenheitTemp - BASE); System.out.println ("Celsius Equivalent: " + celsiusTemp); } Compile and run the code using the java compiler and interpreter commands.