0

I received this source code: http://www.sbbic.org/split.zip under the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0

It came to me from the author without documentation or support (the author doesn't have the time right now, he is writing a book). My knowledge of Java is very limited.

Can someone tell me how to run the application in order to split the words in columns.txt file that is included in the source?

I've looked around in TextSegmenter.java trying to find how it should be called on the command line, but I have not been successful.

If I call: java com\whitemagicsoftware\dictionary\TextSegmenter lexicon.csv columns.txt I get this error:

Exception in thread "main" java.lang.NoClassDefFoundError: com\whitemagicsoftwar e\dictionary\TextSegmenter (wrong name: com/whitemagicsoftware/dictionary/TextSe gmenter) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:620) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12 4) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$000(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

I tried putting it into a .jar (again with limited experience, I only zipped the files with manually created manifest files included), but it is unable to load.

I am a newbee - sorry if this is a dumb question, but I would appreciate your help!

The purpose of the script is to break words that are joined (ex. "addresstype") into separate words (ex. "address" and "type"). The hope is to use this script in breaking words for the Khmer language which uses no spaces between words.

Thank you!

Nathan
  • 1,483
  • 3
  • 18
  • 41

1 Answers1

3

You are missing external libraries on the CLASSPATH. You have to set the CLASSPATH environment variable, or pass a classpath to the java command via the -cp option, like

 java -cp externallib.jar:otherlib.jar -jar myjar.jar
Daniel
  • 27,718
  • 20
  • 89
  • 133
  • In the build segmenter.bat.txt of the source there is reference to -cp ^../jasperreports/lib;^../jasperreports/lib/*;^../jasperreports/dist;^../jasperreports/dist/* ^com\whitemagicsoftware\dictionary\*.java I had downloaded jasperreports from sourceforge (http://sourceforge.net/projects/jasperreports/), thinking that might be part of the problem, but I wasn't able to get the TextSegmenter to run. I get this error: Exception in thread "main" java.lang.NoClassDefFoundError: com\whitemagicsoftware\dictionary\TextSegmenter/class Sorry - I am a newbee! – Nathan Jan 31 '11 at 04:41
  • The ^'s look suspicious for me. Also, a .bat.txt is stupid, are you sure this isn't just a .bat? – Daniel Jan 31 '11 at 04:46
  • yes, it would need to be renamed it to .bat of course (I just referred to it by what it was called in the source). Using the line in the .bat file does compile the source into .class files, but I still can't figure out how to run the actual program. – Nathan Jan 31 '11 at 08:23
  • Ok, looking more into what you said, I found out how to access it. I enter: java -classpath D:\split com.whitemagicsoftware.dictionary.TextSegmenter and then I get a prompt asking where the files are. Thanks! – Nathan Jan 31 '11 at 08:58