SlideShare a Scribd company logo
C o n c e p t s o f J a v a P r o g r a m m i n g Page 9
Common Errors for Beginners
Consider a class named Test is saved in a file Test.java and saved in D: Java directory
class Test
{
public static void main(String rk[])
{
System.out.println("Error???");
}
}
Case 1: javac is not recognized as an internal or external command
This error occurs because you have not set the environment variable in your machine. Follow
the following steps:
1. Copy the path up to bin folder in jdk. (C:Program FilesJavajdk1.8.0_65bin)
2. Right click on My Computer icon on desktop. Then follow the following
Properties  Advanced system settings  Advanced  Environment Variables
3. In System Variables click on New and fill the Variable name and Variable Value as shown
below:
C o n c e p t s o f J a v a P r o g r a m m i n g Page 10
Case 2: Annotation processing
While compiling your Java program file name must be given with .java extension.
 javac Test.java
Case 3: Could not find or load main class Test.java
While executing your Java program name of the class is to be passed (without any extension)
which contains the main method:
public static void main (String rk[])
NOTE: In a normal java program, if you will try to execute a class which does not contain the
above mentioned main method, then you will get the same error message. As the java run time
environment expects that method in the class whose name you are passing during the execution.
C o n c e p t s o f J a v a P r o g r a m m i n g Page 11
Case 4: file not found: Test.java
This error occurs because the file named Test.java is not located in the current working
directory. So check whether the file is saved in that location or not?
Then either change the current working directory in your command prompt or change the name
of the file.
In the above case the file is saved in D: Java but we are working in directory C:Usershp
So we need to change the directory as shown below:
The same error may be seen if you are in the correct working directory but the file name is
different while compiling that.
If we write any other file name instead of Test.java (e.g. javac Test1.java or javac test.java), It
will result in the same error.
C o n c e p t s o f J a v a P r o g r a m m i n g Page 12
Case 5: Reached end of file while parsing
This error occurs when you have missed any closing braces in your program as in this program:
class Test
{
public static void main(String rk[])
{
System.out.println("Error???");
}
C o n c e p t s o f J a v a P r o g r a m m i n g Page 13
Case 6: class, interface, or enum expected
This error arises due to different reasons.
(A) When you have added some extra braces as shown in the code below:
(B) When you have used class/interface keywords incorrectly as in the code below class is
written as Class. Java is case sensitive and all the keywords are in lower case.
class Test
{
public static void main(String rk[])
{
System.out.println("Error???");
}
} }
Class Test
{
public static void main(String rk[])
{
System.out.println("Error???");
}
}
C o n c e p t s o f J a v a P r o g r a m m i n g Page 14
Case 7: class TestJava is public, should be declared in a file named TestJava.java
This error occurs when you have created a public class but saved in a file with some other name.
Every public class must be saved in a .java file named as the name of the class, whereas other
classes can be saved with any name.
NOTE: It means that in a .java file you can define N number of classes and interfaces but
at most one of them can be public and the name of the file must be same as the name of the
public class.
 The above classes can be saved in a single .java file but the file must
be named as TestJava.java.
class Test {
public static void main(String rk[])
{
System.out.println("Error???");
}
}
public class TestJava {
void testingJava()
{
System.out.println("Inside testingJava Method...");
}
}
C o n c e p t s o f J a v a P r o g r a m m i n g Page 15
Case 8: cannot find symbol
This error occurs when you are referring to a variable which does not exist and the ^ is pointing
to that variable.
In the above case string symbol does not exist as we have used string instead of String (String is
a predefined class in java.lang package).
Case 9: package does not exist
Similar to the previous case we have used system instead of System in our program. System is a
predefined class in java.lang package.
C o n c e p t s o f J a v a P r o g r a m m i n g Page 16
Case 10: ‘;’ expected
This error occurs because we have missed ‘;’ after the statement.

More Related Content

What's hot (20)

Packages and interfaces
Packages and interfacesPackages and interfaces
Packages and interfaces
bhuvaneshwariA5
 
Introduction to java
Introduction to  javaIntroduction to  java
Introduction to java
Kalai Selvi
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packages
VINOTH R
 
Access modifiers in java
Access modifiers in javaAccess modifiers in java
Access modifiers in java
Madishetty Prathibha
 
Java program structure
Java program structureJava program structure
Java program structure
shalinikarunakaran1
 
Class notes(week 7) on packages
Class notes(week 7) on packagesClass notes(week 7) on packages
Class notes(week 7) on packages
Kuntal Bhowmick
 
Packages and Interfaces
Packages and InterfacesPackages and Interfaces
Packages and Interfaces
AkashDas112
 
Java access modifiers
Java access modifiersJava access modifiers
Java access modifiers
Srinivas Reddy
 
Interfaces In Java
Interfaces In JavaInterfaces In Java
Interfaces In Java
parag
 
Java packages
Java packagesJava packages
Java packages
Jeffrey Quevedo
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Nuha Noor
 
Packages and interfaces
Packages and interfacesPackages and interfaces
Packages and interfaces
vanithaRamasamy
 
JAVA PROGRAMMING – Packages - Stream based I/O
JAVA PROGRAMMING – Packages - Stream based I/O JAVA PROGRAMMING – Packages - Stream based I/O
JAVA PROGRAMMING – Packages - Stream based I/O
Jyothishmathi Institute of Technology and Science Karimnagar
 
Interface in java ,multiple inheritance in java, interface implementation
Interface in java ,multiple inheritance in java, interface implementationInterface in java ,multiple inheritance in java, interface implementation
Interface in java ,multiple inheritance in java, interface implementation
HoneyChintal
 
Packages in java
Packages in javaPackages in java
Packages in java
Elizabeth alexander
 
Java package
Java packageJava package
Java package
CS_GDRCST
 
Pi j4.1 packages
Pi j4.1 packagesPi j4.1 packages
Pi j4.1 packages
mcollison
 
Packages in java
Packages in javaPackages in java
Packages in java
Abhishek Khune
 
Unit 3 Java
Unit 3 JavaUnit 3 Java
Unit 3 Java
arnold 7490
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
Arati Gadgil
 

Similar to Common Programming Errors by Beginners in Java (20)

PAGE 1Input output for a file tutorialStreams and File IOI.docx
PAGE  1Input output for a file tutorialStreams and File IOI.docxPAGE  1Input output for a file tutorialStreams and File IOI.docx
PAGE 1Input output for a file tutorialStreams and File IOI.docx
alfred4lewis58146
 
Unit2 java
Unit2 javaUnit2 java
Unit2 java
mrecedu
 
01-ch01-1-println.ppt java introduction one
01-ch01-1-println.ppt java introduction one01-ch01-1-println.ppt java introduction one
01-ch01-1-println.ppt java introduction one
ssuser656672
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satya
Satya Johnny
 
Adv kvr -satya
Adv  kvr -satyaAdv  kvr -satya
Adv kvr -satya
Jyothsna Sree
 
Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz
SAurabh PRajapati
 
Java
JavaJava
Java
tintinsan
 
Java bad coding practices
Java bad coding practicesJava bad coding practices
Java bad coding practices
Gustavo Carrion, MiT
 
香港六合彩
香港六合彩香港六合彩
香港六合彩
cctv
 
Object Oriented Programming - Java
Object Oriented Programming -  JavaObject Oriented Programming -  Java
Object Oriented Programming - Java
Daniel Ilunga
 
ExtraFileIO.pptx
ExtraFileIO.pptxExtraFileIO.pptx
ExtraFileIO.pptx
NguynThiThanhTho
 
How to run java program without IDE
How to run java program without IDEHow to run java program without IDE
How to run java program without IDE
Shweta Oza
 
Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMLecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVM
manish kumar
 
DAY_1.1.pptx
DAY_1.1.pptxDAY_1.1.pptx
DAY_1.1.pptx
ishasharma835109
 
香港六合彩
香港六合彩香港六合彩
香港六合彩
baoyin
 
Java programming-examples
Java programming-examplesJava programming-examples
Java programming-examples
Mumbai Academisc
 
Advanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAdvanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sir
AVINASH KUMAR
 
Basics of java 2
Basics of java 2Basics of java 2
Basics of java 2
Raghu nath
 
Decompiling Java - SCAM2009 Presentation
Decompiling Java - SCAM2009 PresentationDecompiling Java - SCAM2009 Presentation
Decompiling Java - SCAM2009 Presentation
James Hamilton
 
stateDatabuild.xml Builds, tests, and runs the project.docx
stateDatabuild.xml      Builds, tests, and runs the project.docxstateDatabuild.xml      Builds, tests, and runs the project.docx
stateDatabuild.xml Builds, tests, and runs the project.docx
whitneyleman54422
 
PAGE 1Input output for a file tutorialStreams and File IOI.docx
PAGE  1Input output for a file tutorialStreams and File IOI.docxPAGE  1Input output for a file tutorialStreams and File IOI.docx
PAGE 1Input output for a file tutorialStreams and File IOI.docx
alfred4lewis58146
 
Unit2 java
Unit2 javaUnit2 java
Unit2 java
mrecedu
 
01-ch01-1-println.ppt java introduction one
01-ch01-1-println.ppt java introduction one01-ch01-1-println.ppt java introduction one
01-ch01-1-println.ppt java introduction one
ssuser656672
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satya
Satya Johnny
 
Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz
SAurabh PRajapati
 
香港六合彩
香港六合彩香港六合彩
香港六合彩
cctv
 
Object Oriented Programming - Java
Object Oriented Programming -  JavaObject Oriented Programming -  Java
Object Oriented Programming - Java
Daniel Ilunga
 
How to run java program without IDE
How to run java program without IDEHow to run java program without IDE
How to run java program without IDE
Shweta Oza
 
Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMLecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVM
manish kumar
 
香港六合彩
香港六合彩香港六合彩
香港六合彩
baoyin
 
Advanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAdvanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sir
AVINASH KUMAR
 
Basics of java 2
Basics of java 2Basics of java 2
Basics of java 2
Raghu nath
 
Decompiling Java - SCAM2009 Presentation
Decompiling Java - SCAM2009 PresentationDecompiling Java - SCAM2009 Presentation
Decompiling Java - SCAM2009 Presentation
James Hamilton
 
stateDatabuild.xml Builds, tests, and runs the project.docx
stateDatabuild.xml      Builds, tests, and runs the project.docxstateDatabuild.xml      Builds, tests, and runs the project.docx
stateDatabuild.xml Builds, tests, and runs the project.docx
whitneyleman54422
 
Ad

More from Ravi_Kant_Sahu (20)

Gui programming (awt)
Gui programming (awt)Gui programming (awt)
Gui programming (awt)
Ravi_Kant_Sahu
 
Event handling
Event handlingEvent handling
Event handling
Ravi_Kant_Sahu
 
Basic IO
Basic IOBasic IO
Basic IO
Ravi_Kant_Sahu
 
List classes
List classesList classes
List classes
Ravi_Kant_Sahu
 
Collection framework
Collection frameworkCollection framework
Collection framework
Ravi_Kant_Sahu
 
String handling(string buffer class)
String handling(string buffer class)String handling(string buffer class)
String handling(string buffer class)
Ravi_Kant_Sahu
 
String handling(string class)
String handling(string class)String handling(string class)
String handling(string class)
Ravi_Kant_Sahu
 
Packages
PackagesPackages
Packages
Ravi_Kant_Sahu
 
Generics
GenericsGenerics
Generics
Ravi_Kant_Sahu
 
Array
ArrayArray
Array
Ravi_Kant_Sahu
 
Keywords and classes
Keywords and classesKeywords and classes
Keywords and classes
Ravi_Kant_Sahu
 
Wrapper classes
Wrapper classesWrapper classes
Wrapper classes
Ravi_Kant_Sahu
 
Methods and constructors
Methods and constructorsMethods and constructors
Methods and constructors
Ravi_Kant_Sahu
 
Java keywords
Java keywordsJava keywords
Java keywords
Ravi_Kant_Sahu
 
Jdbc
JdbcJdbc
Jdbc
Ravi_Kant_Sahu
 
Classes and Nested Classes in Java
Classes and Nested Classes in JavaClasses and Nested Classes in Java
Classes and Nested Classes in Java
Ravi_Kant_Sahu
 
Operators in java
Operators in javaOperators in java
Operators in java
Ravi_Kant_Sahu
 
Control structures in Java
Control structures in JavaControl structures in Java
Control structures in Java
Ravi_Kant_Sahu
 
Swing api
Swing apiSwing api
Swing api
Ravi_Kant_Sahu
 
Genesis and Overview of Java
Genesis and Overview of Java Genesis and Overview of Java
Genesis and Overview of Java
Ravi_Kant_Sahu
 
Ad

Recently uploaded (20)

WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODSWIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
samueljackson3773
 
Artificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowyArtificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowy
dominikamizerska1
 
How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdfHow Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
 
Computer_vision-photometric_image_formation.pdf
Computer_vision-photometric_image_formation.pdfComputer_vision-photometric_image_formation.pdf
Computer_vision-photometric_image_formation.pdf
kumarprem6767merp
 
A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...
A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...
A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...
Journal of Soft Computing in Civil Engineering
 
Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)
pelumiadigun2006
 
SEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair KitSEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair Kit
projectultramechanix
 
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdfRearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Takumi Amitani
 
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptxDevelopment of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
aniket862935
 
Structure of OS ppt Structure of OsS ppt
Structure of OS ppt Structure of OsS pptStructure of OS ppt Structure of OsS ppt
Structure of OS ppt Structure of OsS ppt
Wahajch
 
Introduction to AI agent development with MCP
Introduction to AI agent development with MCPIntroduction to AI agent development with MCP
Introduction to AI agent development with MCP
Dori Waldman
 
3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt
engaash9
 
Présentation_gestion[1] [Autosaved].pptx
Présentation_gestion[1] [Autosaved].pptxPrésentation_gestion[1] [Autosaved].pptx
Présentation_gestion[1] [Autosaved].pptx
KHADIJAESSAKET
 
Flow Chart Proses Bisnis prosscesss.docx
Flow Chart Proses Bisnis prosscesss.docxFlow Chart Proses Bisnis prosscesss.docx
Flow Chart Proses Bisnis prosscesss.docx
rifka575530
 
Research_Sensitization_&_Innovative_Project_Development.pptx
Research_Sensitization_&_Innovative_Project_Development.pptxResearch_Sensitization_&_Innovative_Project_Development.pptx
Research_Sensitization_&_Innovative_Project_Development.pptx
niranjancse
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
djiceramil
 
May 2025: Top 10 Read Articles Advanced Information Technology
May 2025: Top 10 Read Articles Advanced Information TechnologyMay 2025: Top 10 Read Articles Advanced Information Technology
May 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
Structural Design for Residential-to-Restaurant Conversion
Structural Design for Residential-to-Restaurant ConversionStructural Design for Residential-to-Restaurant Conversion
Structural Design for Residential-to-Restaurant Conversion
DanielRoman285499
 
IntroSlides-June-GDG-Cloud-Munich community [email protected]
IntroSlides-June-GDG-Cloud-Munich community gathering@Netlight.pdfIntroSlides-June-GDG-Cloud-Munich community gathering@Netlight.pdf
IntroSlides-June-GDG-Cloud-Munich community [email protected]
Luiz Carneiro
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdfIrja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODSWIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
samueljackson3773
 
Artificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowyArtificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowy
dominikamizerska1
 
How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdfHow Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
 
Computer_vision-photometric_image_formation.pdf
Computer_vision-photometric_image_formation.pdfComputer_vision-photometric_image_formation.pdf
Computer_vision-photometric_image_formation.pdf
kumarprem6767merp
 
Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)
pelumiadigun2006
 
SEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair KitSEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair Kit
projectultramechanix
 
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdfRearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Takumi Amitani
 
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptxDevelopment of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
Development of Portable Biomass Briquetting Machine (S, A & D)-1.pptx
aniket862935
 
Structure of OS ppt Structure of OsS ppt
Structure of OS ppt Structure of OsS pptStructure of OS ppt Structure of OsS ppt
Structure of OS ppt Structure of OsS ppt
Wahajch
 
Introduction to AI agent development with MCP
Introduction to AI agent development with MCPIntroduction to AI agent development with MCP
Introduction to AI agent development with MCP
Dori Waldman
 
3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt
engaash9
 
Présentation_gestion[1] [Autosaved].pptx
Présentation_gestion[1] [Autosaved].pptxPrésentation_gestion[1] [Autosaved].pptx
Présentation_gestion[1] [Autosaved].pptx
KHADIJAESSAKET
 
Flow Chart Proses Bisnis prosscesss.docx
Flow Chart Proses Bisnis prosscesss.docxFlow Chart Proses Bisnis prosscesss.docx
Flow Chart Proses Bisnis prosscesss.docx
rifka575530
 
Research_Sensitization_&_Innovative_Project_Development.pptx
Research_Sensitization_&_Innovative_Project_Development.pptxResearch_Sensitization_&_Innovative_Project_Development.pptx
Research_Sensitization_&_Innovative_Project_Development.pptx
niranjancse
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
djiceramil
 
May 2025: Top 10 Read Articles Advanced Information Technology
May 2025: Top 10 Read Articles Advanced Information TechnologyMay 2025: Top 10 Read Articles Advanced Information Technology
May 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
Structural Design for Residential-to-Restaurant Conversion
Structural Design for Residential-to-Restaurant ConversionStructural Design for Residential-to-Restaurant Conversion
Structural Design for Residential-to-Restaurant Conversion
DanielRoman285499
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdfIrja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 

Common Programming Errors by Beginners in Java

  • 1. C o n c e p t s o f J a v a P r o g r a m m i n g Page 9 Common Errors for Beginners Consider a class named Test is saved in a file Test.java and saved in D: Java directory class Test { public static void main(String rk[]) { System.out.println("Error???"); } } Case 1: javac is not recognized as an internal or external command This error occurs because you have not set the environment variable in your machine. Follow the following steps: 1. Copy the path up to bin folder in jdk. (C:Program FilesJavajdk1.8.0_65bin) 2. Right click on My Computer icon on desktop. Then follow the following Properties  Advanced system settings  Advanced  Environment Variables 3. In System Variables click on New and fill the Variable name and Variable Value as shown below:
  • 2. C o n c e p t s o f J a v a P r o g r a m m i n g Page 10 Case 2: Annotation processing While compiling your Java program file name must be given with .java extension.  javac Test.java Case 3: Could not find or load main class Test.java While executing your Java program name of the class is to be passed (without any extension) which contains the main method: public static void main (String rk[]) NOTE: In a normal java program, if you will try to execute a class which does not contain the above mentioned main method, then you will get the same error message. As the java run time environment expects that method in the class whose name you are passing during the execution.
  • 3. C o n c e p t s o f J a v a P r o g r a m m i n g Page 11 Case 4: file not found: Test.java This error occurs because the file named Test.java is not located in the current working directory. So check whether the file is saved in that location or not? Then either change the current working directory in your command prompt or change the name of the file. In the above case the file is saved in D: Java but we are working in directory C:Usershp So we need to change the directory as shown below: The same error may be seen if you are in the correct working directory but the file name is different while compiling that. If we write any other file name instead of Test.java (e.g. javac Test1.java or javac test.java), It will result in the same error.
  • 4. C o n c e p t s o f J a v a P r o g r a m m i n g Page 12 Case 5: Reached end of file while parsing This error occurs when you have missed any closing braces in your program as in this program: class Test { public static void main(String rk[]) { System.out.println("Error???"); }
  • 5. C o n c e p t s o f J a v a P r o g r a m m i n g Page 13 Case 6: class, interface, or enum expected This error arises due to different reasons. (A) When you have added some extra braces as shown in the code below: (B) When you have used class/interface keywords incorrectly as in the code below class is written as Class. Java is case sensitive and all the keywords are in lower case. class Test { public static void main(String rk[]) { System.out.println("Error???"); } } } Class Test { public static void main(String rk[]) { System.out.println("Error???"); } }
  • 6. C o n c e p t s o f J a v a P r o g r a m m i n g Page 14 Case 7: class TestJava is public, should be declared in a file named TestJava.java This error occurs when you have created a public class but saved in a file with some other name. Every public class must be saved in a .java file named as the name of the class, whereas other classes can be saved with any name. NOTE: It means that in a .java file you can define N number of classes and interfaces but at most one of them can be public and the name of the file must be same as the name of the public class.  The above classes can be saved in a single .java file but the file must be named as TestJava.java. class Test { public static void main(String rk[]) { System.out.println("Error???"); } } public class TestJava { void testingJava() { System.out.println("Inside testingJava Method..."); } }
  • 7. C o n c e p t s o f J a v a P r o g r a m m i n g Page 15 Case 8: cannot find symbol This error occurs when you are referring to a variable which does not exist and the ^ is pointing to that variable. In the above case string symbol does not exist as we have used string instead of String (String is a predefined class in java.lang package). Case 9: package does not exist Similar to the previous case we have used system instead of System in our program. System is a predefined class in java.lang package.
  • 8. C o n c e p t s o f J a v a P r o g r a m m i n g Page 16 Case 10: ‘;’ expected This error occurs because we have missed ‘;’ after the statement.