R.Sama R.Sama - 3 months ago 32
Java Question

why is this throwing a no such method exception?

Trying to figure out why this is throwing up a no such method exception...

Exception in thread "main" java.lang.NoSuchMethodException: TestMain.main([Ljava.lang.String;)
at java.lang.Class.getMethod(Class.java:1786)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:126)

It's a Java app using jpl.jar (SWI Prolog's Java module).

Here is a snippet of the class I've written:

public class HelperClass {

public HelperClass(String inputFileStr) {
inputFileName = ("Prolog_Files/" + inputFileStr);
// knowledgeBaseName = knowledgeBaseNameStr;

public void loadKB() {
knowledgeBase = new Query("consult(\'" + inputFileName + "\')");

And the small testing class I've created for it. Should just load the .pl file as a new query into Prolog, followed by processing it as a knowledgebase.

public class TestMain {

public static void Main(String[] args) {
HelperClass helper = new HelperClass("file.pl");




It should be

public static void main(String[] args) {}

instead of

public static void Main(String[] args) {}

m of method main should be in lowercase. In your code it's in upper case