1

Hey community I have this rookie problem so if anyone could help that would be great :)

So here it goes...

I'm trying to test the stanford NLP parser by trying to run the java demo file which is included in the file you can download from here

My problem is probably on the imports of the classes included in the .jar files..I tried the solutions on some other stackoverflow threads such as doing
javac -cp "jar/path/number/1";"jar/path/number/2" ParserDemo.java
but the
java -cp "jar/path/number/1";"jar/path/number/2" ParserDemo
command didn't work.

I also tried to extract every jar file in a common folder but then I got the bad class file error..

So what's the move here? How can I solve this ?

P.S. please don't propose as a solution to use the online version of the parser.

EDIT: I'm using Windows 8.1 just in case somebody needs to know

catchiecop
  • 363
  • 4
  • 24
  • Did `javac` work? Did it create a file called ParseDemo.class? – Michael Lloyd Lee mlk Nov 03 '15 at 15:45
  • 4
    How exactly does your command look like? Did you include jar files names or maybe added `jars/location/*` wildcard to include all jar files from directory. Also what do you mean by "command didn't work"? Do you get any error? – Pshemo Nov 03 '15 at 15:49
  • Maybe this will interest you http://stackoverflow.com/questions/219585/setting-multiple-jars-in-java-classpath – Pshemo Nov 03 '15 at 15:52
  • @mlk yeah it did, I had done the PATH modification needed.. – catchiecop Nov 03 '15 at 16:02
  • @Pshemo I included the jar files by name like "jarsFolder/jarFile.jar" and after the java command I get the error "Could not find or load main class ParserDemo" however a .class file exists – catchiecop Nov 03 '15 at 16:02
  • 2
    Is "." included in your path? Try `java -cp ".;jar/path/number/1";"jar/path/number/2" ParserDemo` – Michael Lloyd Lee mlk Nov 03 '15 at 16:03
  • Where is `ParserDemo` class located (does it have package declaration?) and from which location you are running your command? – Pshemo Nov 03 '15 at 16:09
  • @Pshemo the ParserDemo class is in a folder on my desktop and I'm running the command from that same location, I updated the question as something proposed worked, I don't know if it's a coincidence if it's not too much trouble you can check it :) – catchiecop Nov 03 '15 at 16:15
  • `.` represents current location and it should also be included in class path. Normally we include it in CLASSPATH system variable to avoid repetition of `-cp .` in command, so if you didn't set it there you need to include it in your command. Anyway you should not post solution as part of question but post it as separate answer (there should be blue button under your post with text similar to "answer your question"). – Pshemo Nov 03 '15 at 16:21

1 Answers1

4

Since it was posted as a comment and I don't know if it would be visible for future reference I'm gonna write the solution down here as proposed by the user mlk

I fixed my java command to java -cp ".;jar/path/number/1";"jar/path/number/2" ParserDemo and it worked perfectly!

This is because the current folder (.) was not included in the classpath so Java could not see the ParserDemo.class file.

Michael Lloyd Lee mlk
  • 14,109
  • 3
  • 40
  • 79
catchiecop
  • 363
  • 4
  • 24