i am wondering what is the problem here.
here text.txt is the input file.
any help will be highly appreciated.

import java.io.*;


  
public class Main{
public static void main(String[] args) throws Exception
{
 File f= new File("text.txt");
BufferedReader in = new BufferedReader(
		   new FileReader(f));
String line = new String(); 
line  = in.readLine();
while(line!=null){
System.out.println(line);
line = in.readLine();
}
}
}

this is what compiler shows
parth@ubuntu:~/Desktop$ javac Main.java
parth@ubuntu:~/Desktop$ java Main.java
Exception in thread "main" java.lang.NoClassDefFoundError: Main.java
at gnu.java.lang.MainThread.run(libgcj.so.11)
Caused by: java.lang.ClassNotFoundException: Main.java not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.11)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.11)
at java.lang.ClassLoader.loadClass(libgcj.so.11)
at java.lang.ClassLoader.loadClass(libgcj.so.11)
at gnu.java.lang.MainThread.run(libgcj.so.11)

The java command takes the name of a class for its argument. You have give it the filename of the source file.
The class name is the name of the class not the name of the file. There is no .class in a class name.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.