I am completely new to Java, just learned a little because I need to run this project: https://github.com/ansjsun/ansj_seg
I have run
mvn compile
and some other stuff.
Now, in ansj_seg/target I have a file named ansj_seg-0.8.jar, which seems important, although I don't know how to use it.
In ansj_seg/src/test/java/org/ansj/demo, there are some demos, and I want to run BaseAnalysisDemo.java, I tried as following.
Step one, I compile using:
javac -classpath ~/Downloads/ansj_seg/target/ansj_seg-0.8.jar BaseAnalysisDemo.java
It works fine and generates BaseAnalysisDemo.class.
But when I try to run it using
java BaseAnalysisDemo
An error occurs:
Exception in thread "main" java.lang.NoClassDefFoundError: BaseAnalysisDemo (wrong name: org/ansj/demo/BaseAnalysisDemo)
I guess I should set some path, but have no idea.
Anyone can help?
BTW, I prefer using command line to Eclipse.
The directory structure is like this(Updated):
\ansj_seg
pom.xml
\src
\main
\java
\org
\ansj
\app
\dic
\domain
...
\resource
...
\test
\java
\org
\ansj
\demo
BaseAnalysisDemo.java
Demo.java
...
\test
...
Here is another question, even if the demo can be run, how can I use this java library in another place? I guess the file ansj_set-0.8.jar should be used. Again, I know nothing about Java.. Any suggestion will be very helpful.
Updated:
If I run with classpath specified:
java -classpath ~/Downloads/ansj_seg/target/ansj_seg-0.8.jar BaseAnalysisDemo
still got an error, but different:
Exception in thread "main" java.lang.NoClassDefFoundError: BaseAnalysisDemo