Java error cannot read

In this Tutorial we want to describe you a code that helps you in understanding a code ErrorcannotRead in java. For this we have a class ErrorcannotRead.In the main method we create an instance of class date.

Java error cannot read

In this Tutorial we want to describe you a code that helps you in understanding a code ErrorcannotRead in java. For this we have a class ErrorcannotRead.In the main method we create an instance of class date.

Java error cannot read

Java error cannot read

     

The Java error cannot read occurred when a programmer do not follow the following condition-

  1. Putting files in the bin directory  where the javac resides.
  2. The default home drive is C:\ go to cd\
  3. A programmer can make your personal room directory mkdir javaroom.
  4. Put your example with java  extension file to my javaroom.
  5. Add a line to your autoexec.bat and reboot the machine.

    SET CLASS PATH=.;C:\javaroom;%CLASSPATH%
     
    (This means current directory )
    ('%CLASS PATH%' means  existing CLASS PATH definition.)
     
  6. Go to javaroom directory
     
     cd javaroom
      
  7. Javac MyFirstProgram.java
      
     Java  MyFirstProgram.

Here is the video tutorial of "How to solve cannot read file in Java?":

Understand with Example

In this Tutorial we want to describe you a code that helps you in understanding a code ErrorcannotRead in java. For this we have a class ErrorcannotRead.In the main method we create an instance of class date. The System.out.print ln is used to print the year by calling a method .get Year ( ).On execution the code show you an error Java Error cannot made Symbol. This error occurred because the programmer write the wrong class name on the command prompt. Therefore the compiler does not reconogised the class name and show you an error ErrorcannotRead.

ErrorcannotRead.java

import java.util.*;

public class ErrorcannotRead {

  public static void  main(String[] args
  {
  Date d=new Date();
  System.out.println(d.getYear());

  }
  }

Output


To resolve this error you have to give the proper file name of the java file.Here in the example our java file name is ErrorcannotRead.java and we are compiling file as ErrorcannotRead1.java

Download code