简体   繁体   中英

Java Runtime error say main method not found for all the program

I have installed java 8. I already set the environment variables for class path.

Error: Main method not found in class Test, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application

I am getting same error for every program that i have written ever in java. All these programs are working fine in other computer but in my system whenever i run java ClassName it is giving me same error. I'm using Android Studio for android app development that is working fine. Java IDE netbeans and IntelliJ is also working fine.

What could cause this problem to JRE?.

class Test{
   public static void main(String[] args) 
  {
    int tax=20;
    double main1=220;
    double total = main1*tax/100;
    System.out.println(total);
}}

This is a sample program:

Compiling using - javac Test.java

Running using - java Test

  1. First of all uninstall java by going into => control panel > program

  2. delete java folder form your C: drive from programfile86 and programfile and if you find folder named as sun delete it as well

  3. In run type appdata this will show you some folder goto each folder and delete file with name of java or sun. Do this for all the folder avilable in this directory

  4. In run type regedit and goto HKEY_USER_DATA and HKEY_LOCAL_MACHINE one by one and then goto software in that delete javasoft folder if you find.. do this in both the folder

delete all the stuff mention above if you find if you don't its ok leave and move to next step.

and then restart your PC

and reinstall java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM