1
import java.util.*;

class sample

{

    public static void main(String arg[])

    {

        System.out.println("Here it is!");

    }

}

How to resolve this Error? I tried set path="..." and set classpath="..." But nothing helped me. Can you help me?

Kaushal28
  • 5,377
  • 5
  • 41
  • 72
Akhil T Mohan
  • 193
  • 1
  • 1
  • 14

2 Answers2

1

mabye you can point the system of where the jdk is. to do this on windows 10, search environment variables in the search bar and click on edit the system environment variables. when you open it, click on environment variables.. at the bottom. you should see 2 sections. in the lower section click new. for the name type JAVA_HOME. it is necessary to have caps but dont include the dot. and for the path, put the directory of the java jdk. always put the folder of the latest version.

  • Yes. i created the Variale name and set the directory to "C:\Program Files\Java\jdk1.8.0_11\". but the problem still persist.. :P – Akhil T Mohan Jul 17 '16 at 13:43
  • did you put the ""? because that could cause problems. also can you please vote up. thanks. i do not know what could cause the problem. if you are using eclipse to make a program in java, try to reinstall the jdk or reinstall eclipse. –  Jul 18 '16 at 04:24
  • did you do the above?? or just try to make a new class file and copy everything to the new file. be carefull with the names of the files and stuff –  Jul 21 '16 at 12:39
0

This happens because filename of the java file is not same as your class name.
In your case file name must be "sample.java".
If you have multiple classes in this file, file name must contains the class that holds the main method.
Make sure you use capital/simple letters correctly.

Lasitha Yapa
  • 4,309
  • 8
  • 38
  • 57