kylo
kylo

Reputation: 3

How to run StanfordCoreNlpDemo.java

I successfully compiled StanfordCoreNlpDemo by running:

javac -cp "*" StanfordCoreNlpDemo.java

and it compiled successfully. I then tried to run it with:

java -cp "*" StanfordCoreNlpDemo

I then received the following error:

Error: Could not find or load main class StanfordCoreNlpDemo

I realize this is a CLASSPATH issue so I tried to add the path to the folder: /some/path/stanford-corenlp-full-2016-10-31/*

Nonetheless, I still get the same error. How do I run StanfordCoreNlpDemo.java?

Upvotes: 0

Views: 252

Answers (1)

Wasi Ahmad
Wasi Ahmad

Reputation: 37771

This is not a problem of StanfordCoreNlpDemo program because I ran that code in Netbeans before. The problem seems associated with classpath issue.

Since the StanfordCoreNlpDemo.java file belongs to a package

package package edu.stanford.nlp.pipeline.demo;

public class StanfordCoreNlpDemo {
    public static final void main(String[] args) throws IOException {
        // code goes here
    } 
}

Then calling the following results in Error: Could not find or load main class TheClassName.

java -cp . StanfordCoreNlpDemo

It must be called with its fully-qualified name:

java -cp . edu.stanford.nlp.pipeline.demo.StanfordCoreNlpDemo

And this edu.stanford.nlp.pipeline.demo directory must exist in the classpath. In this example, ., meaning the current directory, is the entirety of classpath. Therefore this particular example must be called from the directory in which edu.stanford.nlp.pipeline.demo exists.

Reference

Upvotes: 1

Related Questions