0% found this document useful (0 votes)
10 views16 pages

Java Programming Overview by Gosling

Uploaded by

stacy russo
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views16 pages

Java Programming Overview by Gosling

Uploaded by

stacy russo
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

AP/ITEC 2610 3.

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 [Link]
Installing Java
Follow the installation instructions for your specific OS
[Link]
• Take note where Java is installed
• check the path for Java
• find the java compiler ([Link] 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

Installing Geany – Text Editor


[Link]
Programming Tradition:

• 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)

Check if a class file is created or not.


Running the source file
• Note that:
• Java interpreter expects the name of the class to execute, not the file
containing the class.
• If the filename is used in the command line, an error will show up!
Debug a Java program
• Install a Java IDE (integrated development environment)
• like NetBeans IDE
• Step through the Java code line by line
• Install a byte code viewer and disassembler
• Such as Krakatau (which uses Python) or dirtyJOE
• Step through the byte code instruction by instruction
Exercises
1. Change the text message in the compiled Java program
• use a Hex Editor, such as HexWorkshop
• in unix you can use the command line tool xxd
2. (i) Use the tools you have learned about to compile a simple Java
program, and decipher the ‘magic code’ at the start of the byte
code of each program.
(ii) Describe the syntax of the ‘magic’ code.
Course Topics
• Designing a class, Objects, Methods and Variables
• Run GUI using Java – Fun and easy
• Inheritance
• File handling
• Advance io
• Interfaces
• Recursion
Evaluation Criteria:
Assignments 30%
In-Person Mid-term Test 20%
Class Participation 10%
In- Person Final Examination 40%
*Make up Assignment - 1
There is no make up for course Mid-term and
Final Exam
Contact Information:
• E-class
* Lectures, Announcements , Assignment uploads ,
Grade posts etc..
• E-mail :
as14@[Link] (*should be used for personal
reasons only)
Zoom contact:
[Link]
pwd=YWpXcFBhZjhCT0psVUhtRWxPMDFZZz09
• Office Hours: Thursdays [2pm- 3pm] * on Zoom.
• TA Contact: Coming up….
Academic Integrity:
[Link]
es/academic-honesty-senate-policy-on/

• No Plagiarism
• No Cheating
• Delays in your final grades or No grade at all.

Common questions

Powered by AI

Java's strict object-oriented nature limits flexibility by requiring every piece of code be structured around objects, which can complicate and lengthen development processes for simpler tasks that might be more efficiently represented without such structure. Efficiency is impacted since even standalone programs must incorporate the full Java environment to run, rather than simply compiling to native machine code .

Debugging Java programs can be conducted using integrated development environments (IDEs) like NetBeans, allowing developers to step through code line by line . Byte code analysis can be performed using byte code viewers and disassemblers such as Krakatau or dirtyJOE, enabling a more granular inspection of compiled Java programs to understand and troubleshoot execution .

The 'public static void main' method serves as the entry point for Java programs. It is the core method called upon to execute the program and from where all other methods are subsequently invoked. Its significance lies in its fixed placement and role, as Java programs are expected to have this method defined in order for the Java interpreter to initiate execution .

Java's main advantages include its 'Write Once, Run Anywhere' (WORA) capability, allowing programs to run on any processor or operating system, and its secure environment due to its highly object-oriented nature . However, drawbacks include execution speed being slower than native machine code, the necessity of the entire Java environment to run even simple programs, a lack of flexibility, and the substantial size of the Java package and libraries .

Changing a text message in a compiled Java program requires modifying the byte code, which can be challenging because it involves understanding the structure of binary files. Tools like Hex Editors (for example, HexWorkshop) or command line tools like xxd can be used to edit the byte code directly. This process is sensitive and error-prone, as incorrect modifications can corrupt the program .

The course's evaluation structure, divided into assignments (30%), a mid-term test (20%), class participation (10%), and a final exam (40%), emphasizes ongoing engagement and comprehensive understanding. This approach ensures students master both theoretical and practical Java skills, reflecting Java's complexity and the necessity for consistent practice and application in learning its features and capabilities .

The course emphasizes designing classes, objects, methods, handling GUIs, inheritance, file handling, advanced I/O, interfaces, and recursion, reflecting Java's comprehensive, object-oriented approach. This focus illustrates Java's extensive capacities and complexity, preparing students with a thorough understanding of both fundamental and advanced programming concepts within Java's paradigms .

To compile and run a Java program from the command line, first create the program using a text editor like vi, emacs, or Kit . Save the program and compile it using the 'javac' command. Ensure a class file is created. To execute, use the 'java' command followed by the class name, not the filename, to avoid errors . Running involves the Java interpreter executing the compiled class file .

The JVM allows Java applications to achieve portability across different operating systems and processors by executing Java byte code. This means that once Java code is compiled into byte code, it can be run on any device that has a JVM, supporting the WORA principle . However, since Java byte code is interpreted by the JVM rather than running as native machine code, there can be a performance trade-off, making Java applications generally slower than applications compiled to native machine code .

Java facilitates GUI programming through frameworks that integrate with the language's object-oriented structure. Creating GUIs requires considerations of class design, inheritance, and interface implementation to ensure the application operates correctly. Java's structure aids in organizing GUI components, although the inherent complexity and setup can be challenging for developers .

You might also like