2

This question was already asked here on Stack Overflow, BTW even after reading the answer provided, I do not manage to add MyOwnAnalyzer, so that I can use it directly from Luke.

Please can someone help me on the right way to do, that is how and what to do so that MyOwnAnalyzer can be usable directly from Luke?

Can I do this (it did not work, may be my included jar are incomplete?):

java -cp .;d:\java\mylibs\MyOwnAnalyzer.jar -jar lukeall-3.5.0.jar

(MyOwnAnalyzer.jar was built from Eclipse and contains : MyOwnAnalyzer.java, MyOwnTokenizer.java, and MyOwnToken.java inside a subdirectory com.MyCompany... Eclipse added META-INF and manifest.mf for me)

Maybe I am wrong in adding classpath and MyOwnAnalyzer.jar with my command line?

Or must I build Luke from source including MyOwnAnalyzer somewhere in its directory?

Or is there something else to include/write so that my analyzer can be usable and imported from Luke? (looks like there is a mechanism to detect all classes that subclasses Analyzer - MyOwnAnalyzer is already declared as "extends Analyzer" )

BTW, even if it not really the same question but still in the same topic of using a custom analyzer from Luke... si I have an Error when using the tab Analyzer Tool I get Error analyzing:com/google/common/io/CharStreams , this lib is included in a jar, where I included a main that do a sample analysis to check and everything work fine when using it alone. If I use it as explained by JPountz, from Luke, I can see MyOwnAnalyzer from all the Luke tabs, but it did not work!

from the Luke code source, I think what throw the exception this is located somewhere inside the method analyze.

Note: The call to CharStreams.toString(input); is to transform the Reader input to a String inside MyOwnTokenizer.

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
user1340802
  • 1,157
  • 4
  • 17
  • 36

1 Answers1

4

Java ignores the -cp option when the -jar option is also used. You need to run Luke this way:

java -cp lukeall-3.5.0.jar;MyOwnAnalyzer.jar org.getopt.luke.Luke
jpountz
  • 9,904
  • 1
  • 31
  • 39
  • Thx a lot! It works! i'm new to Java and i do not know that! Classpath troubles are often giving me headache :/ – user1340802 Jun 26 '12 at 07:44
  • BTW, even if it not the same question, i have an Error when using the tab _analyzer Tool_ I get Error analyzing:com/google/common/io/CharStreams , this lib is included in a jar, where i included a main that do a sample analysis to check and everything work fine when using it alone. If i use it as explained, from Luke, i can see MyOwnAnalyzer from all the Luke tabs, but it did not work! note: The call to CharStreams.toString(input); is to transform the Reader input to a String inside myOwnTokenizer. – user1340802 Jun 26 '12 at 08:52
  • did you add the JAR containing com.google.common.io.CharStreams (which is Guava I guess) to the classpath? – jpountz Jun 26 '12 at 11:58
  • well, looks like you continue to point me my numerous misunderstandings... i actually had to had guava to CP... `java -cp lukeall-3.5.0.jar;MyOwnAnalyzer.jar;guava-11.0.2.jar org.getopt.luke.Luke` but, here is my misunderstanding, i already added it to the bundled `MyOwnAnalyzer.jar` and to the classpath bundled inside this Jar, so i was thinking i do not have to add it anymore! so i always had to do so? (or i have missed something?) – user1340802 Jun 26 '12 at 12:17