Search code examples
javajsonmethodsprogram-entry-point

Main Method Not Found - JSON Related


I am following an example given on http://www.tutorialspoint.com/json/json_quick_guide.htm

import org.json.simple.JSONObject;

class JsonEncodeDemo {

   public static void main(String[] args){
      JSONObject obj = new JSONObject();

      obj.put("name", "foo");
      obj.put("num", new Integer(100));
      obj.put("balance", new Double(1000.21));
      obj.put("is_vip", new Boolean(true));

      System.out.print(obj);
   }
}

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

What seems to be the problem?

Many thanks in advance.


Solution

  • can you write the code using to compile and run your program? I guess there might be a typo.