JavaProgramming
JavaProgramming
00
Object Oriented
Programming
Lecture -1
Sept, 8th 2022 (4pm-7pm)
Java Programming Language
James Gosling
Creator of Java
Year of launch :
May 23, 1995; 27 years
ago
Company:
Sun Microsystems
(now a part of Oracle)
Features of Java
• Write once, run anywhere (WORA)
• any processor, any operating system
• Java programs even run in your web browser
• similar syntax to C/C++
• secure environment
• highly object oriented
Drawbacks of Java
• Java compiles to byte code and executed by a Java Virtual Machine
• slower than native machine code
• not interactive like an interpreted language like Python
• Totally ‘object oriented’
• you can’t do anything without ‘objects’
• No stand alone programs
• you need the whole Java environment to run even the simplest Java program
• Not lean and mean
• Java package is about 300MB, with 175MB of libraries
• Java is not very flexible
• e.g. the main program must be called Main.java
Installing Java
Follow the installation instructions for your specific OS
https://www.java.com/en/download/help/download_options.html
• Take note where Java is installed
• check the path for Java
• find the java compiler (javac.exe in Windows)
• use the where or whereis program to find java
• explore other executable programs (*.exe in Windows)
• run java from the command line
• run java using the complete path and full program name
Your first Java
Program
• Java is compiled from the command line
• try to create your first program with a
command line text editor
• like vi or emacs in Unix
• or Kit in Windows
• be sure you know where you save the
program
• use javac to compile the program
• use hex editor to look at compiled code
• read the text in the byte code
• run the Java program (*.class)
Finding java
Windows
Unix
• The keyword public static void main is the means by which you create a
main method within the Java application. It's the core method of the
program and calls all others.
Compiling Java file (only once)
• No Plagiarism
• No Cheating
• Delays in your final grades or No grade at all.