SlideShare uma empresa Scribd logo
1 de 8
Baixar para ler offline
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.

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Packages and interfaces
Packages and interfacesPackages and interfaces
Packages and interfaces
 
Introduction to java
Introduction to  javaIntroduction to  java
Introduction to java
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packages
 
Access modifiers in java
Access modifiers in javaAccess modifiers in java
Access modifiers in java
 
Java program structure
Java program structureJava program structure
Java program structure
 
Class notes(week 7) on packages
Class notes(week 7) on packagesClass notes(week 7) on packages
Class notes(week 7) on packages
 
Packages and Interfaces
Packages and InterfacesPackages and Interfaces
Packages and Interfaces
 
Java access modifiers
Java access modifiersJava access modifiers
Java access modifiers
 
Interfaces In Java
Interfaces In JavaInterfaces In Java
Interfaces In Java
 
Java packages
Java packagesJava packages
Java packages
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Packages and interfaces
Packages and interfacesPackages and interfaces
Packages and interfaces
 
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
 
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
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Java package
Java packageJava package
Java package
 
Pi j4.1 packages
Pi j4.1 packagesPi j4.1 packages
Pi j4.1 packages
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Unit 3 Java
Unit 3 JavaUnit 3 Java
Unit 3 Java
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 

Semelhante a Common Programming Errors by Beginners in Java

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.docxalfred4lewis58146
 
Unit2 java
Unit2 javaUnit2 java
Unit2 javamrecedu
 
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 onessuser656672
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satyaSatya 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 - JavaDaniel 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 IDEShweta 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, JVMmanish 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 sirAVINASH KUMAR
 
Basics of java 2
Basics of java 2Basics of java 2
Basics of java 2Raghu nath
 
Decompiling Java - SCAM2009 Presentation
Decompiling Java - SCAM2009 PresentationDecompiling Java - SCAM2009 Presentation
Decompiling Java - SCAM2009 PresentationJames 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.docxwhitneyleman54422
 

Semelhante a 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
 
Unit2 java
Unit2 javaUnit2 java
Unit2 java
 
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
 
Adv kvr -satya
Adv  kvr -satyaAdv  kvr -satya
Adv kvr -satya
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satya
 
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
 
Java
JavaJava
Java
 
Java bad coding practices
Java bad coding practicesJava bad coding practices
Java bad coding practices
 
香港六合彩
香港六合彩香港六合彩
香港六合彩
 
Object Oriented Programming - Java
Object Oriented Programming -  JavaObject Oriented Programming -  Java
Object Oriented Programming - Java
 
ExtraFileIO.pptx
ExtraFileIO.pptxExtraFileIO.pptx
ExtraFileIO.pptx
 
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
 
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
 
DAY_1.1.pptx
DAY_1.1.pptxDAY_1.1.pptx
DAY_1.1.pptx
 
香港六合彩
香港六合彩香港六合彩
香港六合彩
 
Java programming-examples
Java programming-examplesJava programming-examples
Java programming-examples
 
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
 
Basics of java 2
Basics of java 2Basics of java 2
Basics of java 2
 
Decompiling Java - SCAM2009 Presentation
Decompiling Java - SCAM2009 PresentationDecompiling Java - SCAM2009 Presentation
Decompiling Java - SCAM2009 Presentation
 
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
 

Mais de Ravi_Kant_Sahu (20)

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

Último

Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLManishPatel169454
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSrknatarajan
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 

Último (20)

Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 

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.