Advanced Programming in Java

Slides:



Advertisements
Similar presentations
COP 3530 JDK Environment Variables. COP 3530 JDK Environment Variables Environment Variables Environment variables are a set of dynamic values that can.
Advertisements

Java Development Kit Installation Guide Sun Microsystems.
Introduction to Java IEEM241 Routing and Fleet Management Feb 3, 2005.
Installing JDK and Tomcat Vijayan Sugumaran Department of DIS Oakland University.
Installing JDK and Tomcat Vijayan Sugumaran Department of DIS Oakland University.
CS115 HOW TO INSTALL THE JAVA DEVELOPMENT KIT (JDK)
Go to the link ( as shown, then choose downloads.
Installing JDK Vijayan Sugumaran Department of DIS Oakland University.
Eclipse Begin at the Beginning. Where to Find it:
CS1020: Intro Workshop. Topics CS1020Intro Workshop Login to UNIX operating system 2. …………………………………… 3. …………………………………… 4. …………………………………… 5. ……………………………………
Guide To UNIX Using Linux Third Edition
Update the PATH variable Trying to run the command: “javac Ex1.java” you’ve may encountered the error: “javac is not recognized as internal or external.
Writing Methods. Create the method Methods, like functions, do something They contain the code that performs the job Methods have two parts.
Introduction to Java.
Command Console Tutorial BCIS 3680 Enterprise Programming.
SERVLETS.
Sadegh Aliakbary Sharif University of Technology Fall 2012.
Installing and Configuring Tomcat A quick guide to getting things set up on Windows.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
Servlets Environment Setup. Agenda:  Setting up Java Development Kit  Setting up Web Server: Tomcat  Setting up CLASSPATH.
Introduction to Shell Script Programming
Shell Scripting Introduction. Agenda What is Shell Scripting? Why use Shell Scripting? Writing and Running a Shell Script Basic Commands -ECHO - REM.
Chapter 1© copyright Janson Industries Java ▮ Java programming concepts ▮ Downloading the JDK ▮ Java coding and executing example This presentation.
© 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures for Java William H. Ford William R. Topp Appendix E The EZJava.
How to Tag a Corpus Using Stanford Tagger. Accuracy All tokens: 97.32% Unknown words: 90.79%
Putting Applets into Web Pages.  Two things are involved in the process of putting applets onto web pages ◦ The.class files of the applet ◦ The html.
1 The EDIT Program The Edit program is a full screen text editor that allows you to: Create text files Create text files Edit an existing text files Edit.
( ) 1 ISYE 7210—Fall 2005 Design of Real-Time Interactive Simulations (in Java) Initial Notes Christine M. Mitchell Director & Professor Center for.
Introduction to Eclipse CSC 216 Lecture 3 Ed Gehringer Using (with permission) slides developed by— Dwight Deugo Nesa Matic
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
9/2/ CS171 -Math & Computer Science Department at Emory University.
Peyman Dodangeh Sharif University of Technology Spring 2014.
Setting Up Eclipse. What is Eclipse? Eclipse is a free, downloadable software that allows us to create, compile, and run JAVA programs.
EIE375 BlueJ: Getting Started Dr Lawrence Cheung.
Installing JDK Vijayan Sugumaran Department of DIS Oakland University.
Java Programming, Second Edition Appendix A Working with Java SDK 1.4.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
1 Installing Java on Your PC. Installing Java To develop Java programs on your PC: Install JDK (Java Development Kit) Add the directory where JDK was.
“Hello World” In Java Mehdi Einali Advanced Programming in Java 1.
Introducing Dreamweaver. Dreamweaver The web development application used to create web pages Part of the Adobe creative suite.
Installing Java on a Home machine For Windows Users: Download/Install: Go to downloads html.
1 Getting Started with C++ Part 1 Windows. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Microsoft.
Java On the ENB 116 Computers The JDK is now available on the ENB 116 computers. You can use a classroom computer rather than your own laptop or CIRCE.
“Hello World” In Java Mehdi Einali Advanced Programming in Java 1.
Settings MySQL Database and JDBC configuration Instructor: Sergey Goldman.
INTERNET APPLICATIONS CPIT405 Install a web server and analyze packets.
CS 201 Lecture 1 (b) Using an IDE Tarik Booker CS 201: Introduction to Programming California State University, Los Angeles.
Tips for using Java with Internet Explorer
© copyright Janson Industries 2014
Installing Java on a Home machine
CS1010: Intro Workshop.
CHAPTER 10 JAVA SCRIPT.
Development Environment Basics
SUSE Linux Enterprise Desktop Administration
The Command Prompt Commands are the way to “do things” in Unix
Testing and Debugging.
Bomgar Remote support software
Operating Microcomputer
Advanced Programming in Java
Installing Java on a Home machine
How to Run a Java Program
JavaTeaching and Importing a github repository
DEBUGGING JAVA PROGRAMS USING ECLIPSE DEBUGGER
Run Java file with Window cmd
New Perspectives on Windows XP
Testing, debugging, and using support libraries
Advanced Programming Behnam Hatami Fall 2017.
CS115 HOW TO INSTALL THE JAVA DEVELOPMENT KIT (JDK)
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
Review of Previous Lesson
Presentation transcript:

Advanced Programming in Java “Hello World” In Java Mehdi Einali

Agenda Review First program in java Variables Methods Conditions Loops

Review Java is Java is platform independent. Write Once, Run Anywhere! Simple object oriented And popular Java is platform independent. Write Once, Run Anywhere!

First Program in java

Hello World Create a file named First.java Copy this lines to the file Java class files have .java extension Note to naming convention Copy this lines to the file Note: File name and class name should be the same.

Setting JAVA_HOME Variable in Windows From : http://www.ntu.edu.sg/home/ehchua/programming/howto/Environment_Variables.html http://www.robertsindall.co.uk/blog/setting-java-home-variable-in-windows/ Environment Variables For Java Applications 1.  What are Environment Variables? Environment variables are global system variables accessible by all the processes running under the Operating System (OS). Environment variables are useful to store system-wide values such as the directories to search for the executable programs (PATH) and the OS version. Examples of environment variables in Windows OS are: COMPUTENAME, USERNAME: stores the computer and current user name. OS: the operating system. SystemRoot: the system root directory. PATH: stores a list of directories for searching executable programs. In setting up JDK and Java applications, you will encounter these environment variables: PATH, CLASSPATH, JAVA_HOME and JRE_HOME. In short: PATH: maintains a list of directories. The OS searches the PATH entries for executable programs, such as Java Compiler (javac) and Java Runtime (java). CLASSPATH: maintain a list of directories (containing many Java class files) and JAR file (a single-file archive of Java classes). The Java Compiler and Java Runtime searches the CLASSPATH entries for Java classes referenced in your program. JAVA_HOME and JRE_HOME: maintain the locations of JDK and JRE installed directory, respectively. 2.  (Windows) How to Set or Change an Environment Variable Variables in Windows are NOT case-sensitive (because the legacy DOS is not case-sensitive). Environment variables are typically named in uppercase, with words joined with underscore (_), e.g., JAVA_HOME. Display Variables and their Values To list all the variables and their values, start a CMD shell (Click "Start" button ⇒ Run ⇒ Enter "cmd") and issue the command "set". To display a particular variable, use command "set varname". For examples, // Display all the variables (in NAME=VALUE pairs) prompt> set COMPUTERNAME=xxxxxxx OS=xxxxxxx PATH=xxxxxxx ....... // Display a particular variable prompt> set COMPUTERNAME COMPUTERNAME=xxxxxx // OR use echo command with variable enclosed within a pair of '%'s prompt> echo %COMPUTERNAME% Set an Environment Variable To set an environment variable permanently in Windows (so that it is available to all the Windows' processes), start the "Control Panel" ⇒ "System" ⇒ (Vista/7/8) "Advanced system settings" ⇒ Switch to "Advanced" tab ⇒ "Environment variables" ⇒ Choose "System Variables" (for all users) or "User Variables" (for this login user only) ⇒ Choose "Edit" (for modifying an existing variable) or "New" (to create a new variable) ⇒ Enter the variable "Name" and "Value". Setting JAVA_HOME Variable in Windows In this example we will set the JAVA_HOME variable in Windows. The JAVA_HOME variable is used by applications to find the Java Development Kit installation. Find JDK Installation Directory First you need to know the installation path for the Java Development Kit. Open the default installation path for the Java Development Kit C:\Program Files\Java or C:\Program Files (x86)\Java There should be a subdirectory like C:\Program Files\Java\jre6 C:\Program Files (x86)\Java\jre6 Set the JAVA_HOME Variable Once you have the JDK installation path: Right-click the My Computer icon on your desktop and select Properties. Click the Advanced tab. Click the Environment Variables button. Under System Variables, click New. Enter the variable name as JAVA_HOME. Enter the variable value (one of the paths mentioned above) as the installation path for the Java Development Kit. Click OK. Click Apply Changes.

Debugging Syntax Error Run-time errors logic or semantic error exceptions logic or semantic error The semantics, or meaning of the program, are wrong intelj hot keys Ctl + Space Invoke code completion. Alt + Enter suggestions for error Ctl + W* select word Ctl + F12 list methods. Alt + Insert smart insert Ctl + Alt + right/left arrow go to recent cursor places Alt + right/left arrow switch right/left tab Ctl + Tab switch tabs crl + e recent files Ctl + n find class Ctl + Shift + n find file Ctl + Shift + f find in files Ctl + y remove lines Ctl + d duplicate lines Shift + Alt + up/down arrow move line up/down F9 run/debug dialoge Shift + F9 debug Alt + F1 then 1 find file in navigator Esc go to main edit page Shift + Esc go to main edit page and close others F12 go to last opened window Alt+5 go to debug window

Java Programs A simple java program is a file The file contains one class The class name equal to the file name The names are case sensitive The class contains a main method When we run the program, the main method is executed

Variables What is a variable? A piece of memory Holds data For example a number, string or Boolean Java variables have a fixed size Platform independence

Java Primitive Types

Arithmetic Operators

Operator Precedence 1 + 2 * 3 = ? is treated as 1 + (2 * 3)

Equality and Relational Operators

Operators

Exercise

Programming strategy

Programming strategy Incremental Development Start with a working program that does something visible, like printing something. Add a small number of lines of code at a time, and test the program after every change. Repeat until the program does what it is supposed to do

Recipe For Failure -1 Non-incremental development If you write more than a few lines of code without compiling and testing, you are asking for trouble Attachment to bad code If you write more than a few lines of code without compiling and testing, you may not be able to debug it

Recipe For Failure -2 Random-walk programming Compiler submission Make a change, run the program, get an error, make a change, run the program, etc The problem is that there is no apparent connection between the outcome of the program and the change. Compiler submission Error messages are useful, but they are not always right. Please think before edit

Khokhan-1

Khokhan-2 Stubborn Crazy Untidy Stochastic Hate other khokhans And Love Chaos

end