SlideShare une entreprise Scribd logo
1  sur  40
Getting to know your Programming Environment
Objectives At the end of the lesson, the student should be able to: ●  Create a Java program using text editor and console in the Linux, Solaris, Windows, Mac OS, or any other OS environment ●  Differentiate between syntax-errors and runtime errors ●  Create a Java program using NetBeans
Definitions ● Console – This is where you type in commands – Examples are Terminal (Linux), MSDOS Command Prompt (Windows)
Definitions ●  Text Editor –  Examples: Notepad, Wordpad, Vi
Definitions ● Integrated Development Environment or IDE – a programming environment integrated into a software application that provides a GUI builder, a text or code editor, a compiler and/or interpreter and a debugger.
My First Java Program 1 public class Hello { 2 3 /** 4 * My first Java program 5 */ 6 public static void main( String[] args ){ 7 8 //prints the string “Hello world” on screen 9 System.out.println(“Hello world”); 10 11 } 12 }
Using Text Editor and Console ● Step 1: Start the Text Editor – To start the Text Editor in Linux, click on Menu-> Accessories-> Text Editor ● Step 2: Open Terminal – To open Terminal in Linux, click on Menu-> System Tools-> Terminal ● Step 3: Write your the source code of your Java program in the Text Editor
Using Text Editor and Console ●  Step 4: Save your Java Program –  Filename: Hello.java –  Folder name: myjavaprograms –  To open the Save dialog box, click on the File menu found on the menubar and then click on Save. –  If the folder myjavaprograms does not exist yet, create the folder
Using Text Editor and Console ●  Step 5: Compiling your program –  Go to the Terminal window –  Go to the folder myjavaprograms where you saved the program –  To compile a Java program, we type in the command: javac [filename] –  So in this case, type in: javac Hello.java During compilation, javac adds a file to the disk called [filename].class, or in this case, Hello.class, which is the actual bytecode.
Using Text Editor and Console ● Step 6: Running the Program – To run your Java program, type in the command: java [filename without the extension] – so in the case of our example, type in: java Hello – You can see on the screen after running the program: "Hello world!"
Using NetBeans IDE
Using NetBeans IDE
Using NetBeans IDE
Using NetBeans IDE
Using NetBeans IDE
Using NetBeans IDE
Using NetBeans IDE
1.What is the name of the package here? 2.Can we create program without package? 3.What is the name of class? 4.What is the difference between class and Class? 5. we are writing main() method to execute program. why not other name like m1()? 6.Can we write more than one main() method ? 7.Why main() method is public? 8.Why main() method is static? 9.Can we write main() method with different argument? Quiz :
6.Can we write more than one main() method in a class ? 7.Why main() method is public? 8.Why main() method is static? 9.Can we write main() method with different argument? Quiz :
1.What is the name of the package here? 2.Can we create program without package? 3.What is the name of class? 4.What is the difference between class and Class? 5. we are writing main() method to execute program. why not other name like m1()? 6.Can we write more than one main() method ? 7.Why main() method is public? 8.Why main() method is static? 9.Can we write main() method with different argument? Quiz :
1.What is the name of the package here? 2.Can we create program without package? 3.What is the name of class? 4.What is the difference between class and Class? 5. we are writing main() method to execute program. why not other name like m1()? 6.Can we write more than one main() method ? 7.Why main() method is public? 8.Why main() method is static? 9.Can we write main() method with different argument? Quiz :
Errors : Syntax Errors ● Syntax Errors Syntax – errors are usually typing errors ● Common Syntax Errors: – misspelled a command in Java – forgot to write a semi-colon at the end of a statement
Example: Syntax Error
Example: Syntax Error
About  main()  method Calling non-static method from main() : Syntax Error
About  main()  method Calling static method :Correct Syntax
About  main()  method In different flavor  :Type 1
About  main()  method In different flavor  :Type 2
About  main()  method In different flavor  :Type 3
About  main()  method Type 1:Runtime error
About  main()  method Type 1a:Runtime error
About  main()  method Type 1b:Runtime error
About  main()  method Type 2:Runtime error
About  main()  method Type 2a:Runtime error
About  main()  method Type 3:Runtime error (without static)
About  main()  method Type 4:Runtime error (without “public”  i.e “default” modifier )
About  main()  method Type 4a:Runtime error (should use “public” modifier)
About  main()  method Type 5:Runtime error (return type should be “void”)
Errors: Runtime Errors ● Run-time Errors – errors that will not display until you run or execute your program – Even programs that compile successfully may display wrong answers if the programmer has not thought through the logical processes and structures of the program. – Examples: ● You want your program to print 100 strings of “Hello world”, but it only printed 99. ● Your program gets an input from the
Summary ● My First Java Program ● Using a Text Editor and Console – Write program – Compile program – Run program ● Errors – Syntax Errors – Runtime Errors

Contenu connexe

Similaire à 2 Getting To Know Your Programing Environment

java 1 new.pdf
java 1 new.pdfjava 1 new.pdf
java 1 new.pdfSulSya
 
Java lab1 manual
Java lab1 manualJava lab1 manual
Java lab1 manualnahalomar
 
Unit2 java
Unit2 javaUnit2 java
Unit2 javamrecedu
 
Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Mohamed Essam
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1sotlsoc
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting StartedMartin Chapman
 
Big Java Chapter 1
Big Java Chapter 1Big Java Chapter 1
Big Java Chapter 1Maria Joslin
 
Core java-introduction
Core java-introductionCore java-introduction
Core java-introductionRamlal Pawar
 
01slide (1)ffgfefge
01slide (1)ffgfefge01slide (1)ffgfefge
01slide (1)ffgfefgebsnl007
 
Unit of competency
Unit of competencyUnit of competency
Unit of competencyloidasacueza
 
Prg 218 entire course
Prg 218 entire coursePrg 218 entire course
Prg 218 entire coursegrades4u
 
Introduction to computer science
Introduction to computer scienceIntroduction to computer science
Introduction to computer scienceumardanjumamaiwada
 

Similaire à 2 Getting To Know Your Programing Environment (20)

java 1 new.pdf
java 1 new.pdfjava 1 new.pdf
java 1 new.pdf
 
Basics of java 1
Basics of java 1Basics of java 1
Basics of java 1
 
Java lab1 manual
Java lab1 manualJava lab1 manual
Java lab1 manual
 
Unit2 java
Unit2 javaUnit2 java
Unit2 java
 
Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Intro to programing with java-lecture 1
Intro to programing with java-lecture 1
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting Started
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Big Java Chapter 1
Big Java Chapter 1Big Java Chapter 1
Big Java Chapter 1
 
Core java-introduction
Core java-introductionCore java-introduction
Core java-introduction
 
Java programming language basics
Java programming language basicsJava programming language basics
Java programming language basics
 
01slide (1)ffgfefge
01slide (1)ffgfefge01slide (1)ffgfefge
01slide (1)ffgfefge
 
Unit of competency
Unit of competencyUnit of competency
Unit of competency
 
Prg 218 entire course
Prg 218 entire coursePrg 218 entire course
Prg 218 entire course
 
lecture 6
 lecture 6 lecture 6
lecture 6
 
Introduction to computer science
Introduction to computer scienceIntroduction to computer science
Introduction to computer science
 
01slide
01slide01slide
01slide
 
01slide
01slide01slide
01slide
 
How java works
How java worksHow java works
How java works
 
How java works
How java worksHow java works
How java works
 

Dernier

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Dernier (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

2 Getting To Know Your Programing Environment

  • 1. Getting to know your Programming Environment
  • 2. Objectives At the end of the lesson, the student should be able to: ● Create a Java program using text editor and console in the Linux, Solaris, Windows, Mac OS, or any other OS environment ● Differentiate between syntax-errors and runtime errors ● Create a Java program using NetBeans
  • 3. Definitions ● Console – This is where you type in commands – Examples are Terminal (Linux), MSDOS Command Prompt (Windows)
  • 4. Definitions ● Text Editor – Examples: Notepad, Wordpad, Vi
  • 5. Definitions ● Integrated Development Environment or IDE – a programming environment integrated into a software application that provides a GUI builder, a text or code editor, a compiler and/or interpreter and a debugger.
  • 6. My First Java Program 1 public class Hello { 2 3 /** 4 * My first Java program 5 */ 6 public static void main( String[] args ){ 7 8 //prints the string “Hello world” on screen 9 System.out.println(“Hello world”); 10 11 } 12 }
  • 7. Using Text Editor and Console ● Step 1: Start the Text Editor – To start the Text Editor in Linux, click on Menu-> Accessories-> Text Editor ● Step 2: Open Terminal – To open Terminal in Linux, click on Menu-> System Tools-> Terminal ● Step 3: Write your the source code of your Java program in the Text Editor
  • 8. Using Text Editor and Console ● Step 4: Save your Java Program – Filename: Hello.java – Folder name: myjavaprograms – To open the Save dialog box, click on the File menu found on the menubar and then click on Save. – If the folder myjavaprograms does not exist yet, create the folder
  • 9. Using Text Editor and Console ● Step 5: Compiling your program – Go to the Terminal window – Go to the folder myjavaprograms where you saved the program – To compile a Java program, we type in the command: javac [filename] – So in this case, type in: javac Hello.java During compilation, javac adds a file to the disk called [filename].class, or in this case, Hello.class, which is the actual bytecode.
  • 10. Using Text Editor and Console ● Step 6: Running the Program – To run your Java program, type in the command: java [filename without the extension] – so in the case of our example, type in: java Hello – You can see on the screen after running the program: "Hello world!"
  • 18. 1.What is the name of the package here? 2.Can we create program without package? 3.What is the name of class? 4.What is the difference between class and Class? 5. we are writing main() method to execute program. why not other name like m1()? 6.Can we write more than one main() method ? 7.Why main() method is public? 8.Why main() method is static? 9.Can we write main() method with different argument? Quiz :
  • 19. 6.Can we write more than one main() method in a class ? 7.Why main() method is public? 8.Why main() method is static? 9.Can we write main() method with different argument? Quiz :
  • 20. 1.What is the name of the package here? 2.Can we create program without package? 3.What is the name of class? 4.What is the difference between class and Class? 5. we are writing main() method to execute program. why not other name like m1()? 6.Can we write more than one main() method ? 7.Why main() method is public? 8.Why main() method is static? 9.Can we write main() method with different argument? Quiz :
  • 21. 1.What is the name of the package here? 2.Can we create program without package? 3.What is the name of class? 4.What is the difference between class and Class? 5. we are writing main() method to execute program. why not other name like m1()? 6.Can we write more than one main() method ? 7.Why main() method is public? 8.Why main() method is static? 9.Can we write main() method with different argument? Quiz :
  • 22. Errors : Syntax Errors ● Syntax Errors Syntax – errors are usually typing errors ● Common Syntax Errors: – misspelled a command in Java – forgot to write a semi-colon at the end of a statement
  • 25. About main() method Calling non-static method from main() : Syntax Error
  • 26. About main() method Calling static method :Correct Syntax
  • 27. About main() method In different flavor :Type 1
  • 28. About main() method In different flavor :Type 2
  • 29. About main() method In different flavor :Type 3
  • 30. About main() method Type 1:Runtime error
  • 31. About main() method Type 1a:Runtime error
  • 32. About main() method Type 1b:Runtime error
  • 33. About main() method Type 2:Runtime error
  • 34. About main() method Type 2a:Runtime error
  • 35. About main() method Type 3:Runtime error (without static)
  • 36. About main() method Type 4:Runtime error (without “public” i.e “default” modifier )
  • 37. About main() method Type 4a:Runtime error (should use “public” modifier)
  • 38. About main() method Type 5:Runtime error (return type should be “void”)
  • 39. Errors: Runtime Errors ● Run-time Errors – errors that will not display until you run or execute your program – Even programs that compile successfully may display wrong answers if the programmer has not thought through the logical processes and structures of the program. – Examples: ● You want your program to print 100 strings of “Hello world”, but it only printed 99. ● Your program gets an input from the
  • 40. Summary ● My First Java Program ● Using a Text Editor and Console – Write program – Compile program – Run program ● Errors – Syntax Errors – Runtime Errors