You missed the build folder. Check it's content.
Exception in thread "main" java.lang.NoClassDefFoundError
amira@amira-VirtualBox:~/CRF$ ls -l build
total 4
drwxrwxr-x 11 amira amira 4096 2012-04-30 20:24 iitb
- Edited
Yes xterm, you're right.xterm wroteYou missed the build folder. Check it's content.
So Amira, as xterm said, please check the contents of your build folder. You should see the same folder structure as the one in the src folder. So from the terminal, navigate to the build folder and issue the command:
java -cp $CLASSPATH iitb.Segment.Segment train -f samples/us50.conf
Assuming that the build folder contains all the compiled source files. If not, then you'll have to use your ant builder. Try the above first and let us know what happens.I tried as you tell me:
amira@amira-VirtualBox:~$ export CRF_HOME=/home/amira/CRF
amira@amira-VirtualBox:~$ cd /home/amira/CRF
amira@amira-VirtualBox:~/CRF$ ./settings.sh
Using CRF_HOME=/home/amira/CRF
Reached Here
Reached Here
Reached Here
Reached Here
amira@amira-VirtualBox:~/CRF$ cd build
amira@amira-VirtualBox:~/CRF/build$ java -cp $CLASSPATH iitb.Segment.Segment train -f samples/us50.conf
Exception in thread "main" java.lang.NoClassDefFoundError: train
Caused by: java.lang.ClassNotFoundException: train
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: train. Program will exit.
Amira, again, in your build folder, could you please go to iitb then Segment then check if inside the Segment folder, there's a Segment.class file?
Another thing is, Please check your Segment.java class inside your source folder, and see how exactly does your program expect to consume the "train" argument. Shouldn't it be preceded with a "-" ? Also check if Segment.java contains a main method.
Another thing is, Please check your Segment.java class inside your source folder, and see how exactly does your program expect to consume the "train" argument. Shouldn't it be preceded with a "-" ? Also check if Segment.java contains a main method.
yes, there is Segment.class in iitb of build folder
amira@amira-VirtualBox:~/CRF/build/iitb$ ls -l Segment
total 68
-rw-rw-r-- 1 amira amira 1732 2012-04-30 20:24 AlphaNumericPreprocessor.class
-rw-rw-r-- 1 amira amira 594 2012-04-30 20:24 BinaryLabelMap.class
-rw-rw-r-- 1 amira amira 7591 2012-04-30 20:24 DataCruncher.class
-rw-rw-r-- 1 amira amira 1332 2012-04-30 20:24 DCTrainData.class
-rw-rw-r-- 1 amira amira 3021 2012-04-30 20:24 DCTrainRecord.class
-rw-rw-r-- 1 amira amira 445 2012-04-30 20:24 LabelMap.class
-rw-rw-r-- 1 amira amira 498 2012-04-30 20:24 Preprocessor.class
-rw-rw-r-- 1 amira amira 13325 2012-04-30 20:24 Segment.class
-rw-rw-r-- 1 amira amira 2160 2012-04-30 20:24 Segment$TestRecord.class
-rw-rw-r-- 1 amira amira 2562 2012-04-30 20:24 TestData.class
-rw-rw-r-- 1 amira amira 3662 2012-04-30 20:24 TestDataWrite.class
-rw-rw-r-- 1 amira amira 328 2012-04-30 20:24 TrainData.class
-rw-rw-r-- 1 amira amira 295 2012-04-30 20:24 TrainRecord.class
the Segment.java contains a main method. And I think that it shoudn'd be nothing before the train argument becauce this line of code in the main method of Segment.java:
public static void main(String argv[]) throws Exception {
if (argv.length < 3) {
System.out.println("Usage: java iitb.Segment.Segment <train|test|calc|all> -f <conf-file>");
return;
}
.
.
.
That being said, please try it without the classpath argument. Just issue this command from inside your build folder:
java iitb.Segment.Segment train -f samples/us50.conf
I still have an error:
amira@amira-VirtualBox:~/CRF/build$ java iitb.Segment.Segment train -f samples/us50.conf
Exception in thread "main" java.io.FileNotFoundException: samples/us50.conf (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:137)
at java.io.FileInputStream.<init>(FileInputStream.java:96)
at iitb.Segment.Segment.parseConf(Segment.java:79)
at iitb.Segment.Segment.main(Segment.java:58)
- Edited
Yes I was going to tell you about it. The filepath that you have provided is incorrect: samples/us50.conf
instead of the samples/us50.conf , please provide the exact path to where your us50.conf file is.
It was under the same directory where you have issued the ls command in the following post:
instead of the samples/us50.conf , please provide the exact path to where your us50.conf file is.
It was under the same directory where you have issued the ls command in the following post:
amira@amira-VirtualBox:~/CRF$ ls -all
total 72
drwxr-xr-x 9 amira amira 4096 2012-05-01 09:23 .
drwxr-xr-x 30 amira amira 4096 2012-04-24 14:32 ..
drwxrwxr-x 3 amira amira 4096 2012-04-30 20:24 build
-rw-r--r-- 1 amira amira 2223 2012-04-29 22:37 build.xml
-rw-r--r-- 1 amira amira 2231 2012-04-25 14:42 build.xml~
-rw-r--r-- 1 amira amira 2223 2012-04-07 05:52 .#build.xml.1.4
drwxr-xr-x 5 amira amira 4096 2012-04-18 08:19 doc
drwxr-xr-x 2 amira amira 4096 2012-04-18 08:19 lib
-rw-r--r-- 1 amira amira 1992 2012-04-07 05:51 LICENSE.txt
-rw-r--r-- 1 amira amira 1028 2012-04-07 05:51 README
-rw-r--r-- 1 amira amira 2400 2012-04-07 05:51 RELEASE-NOTES
drwxr-xr-x 5 amira amira 4096 2012-04-18 08:19 samples
-rwxr-xr-x 1 amira amira 470 2012-05-01 09:23 settings.sh
-rwxr-xr-x 1 amira amira 470 2012-05-01 09:22 settings.sh~
drwxr-xr-x 3 amira amira 4096 2012-04-18 08:19 src
drwxr-xr-x 3 amira amira 4096 2012-04-18 08:19 test
drwxr-xr-x 2 amira amira 4096 2012-04-18 08:19 testdata
-rw-r--r-- 1 amira amira 2908 2012-04-07 05:51 third-party-license.txt
Navigate to the "samples" folder from the list above and issue the command pwd
This will output the current working directory. Copy this same path and provide it as an argument to your java command instead of samples/us50.conf. Your resulting path should be something like: YOUR_NEW_PATH/us50.conf
I do the following, but I still have error:
amira@amira-VirtualBox:~/CRF/build$ java iitb.Segment.Segment train -f /home/amira/CRF/samples/us50.conf
I/O Errorjava.io.FileNotFoundException: samples/data/us50/us50.train.tagged (No such file or directory)
the content of the samples folder is :
amira@amira-VirtualBox:~/CRF$ ls -l samples
total 16
drwxr-xr-x 3 amira amira 4096 2012-04-18 08:19 data
drwxr-xr-x 3 amira amira 4096 2012-04-18 08:19 learntModels
drwxr-xr-x 3 amira amira 4096 2012-04-18 08:19 out
-rwxr-xr-x 1 amira amira 93 2012-04-07 05:52 us50.conf
- Edited
Apparently, the us50.conf expects the rest of the needed files to be provided as well.
I need you to navigate to the directory where you got the following output in one of your posts:
I need you to navigate to the directory where you got the following output in one of your posts:
amira@amira-VirtualBox:~/CRF$ ls -all
total 72
drwxr-xr-x 9 amira amira 4096 2012-05-01 09:23 .
drwxr-xr-x 30 amira amira 4096 2012-04-24 14:32 ..
drwxrwxr-x 3 amira amira 4096 2012-04-30 20:24 build
-rw-r--r-- 1 amira amira 2223 2012-04-29 22:37 build.xml
-rw-r--r-- 1 amira amira 2231 2012-04-25 14:42 build.xml~
-rw-r--r-- 1 amira amira 2223 2012-04-07 05:52 .#build.xml.1.4
drwxr-xr-x 5 amira amira 4096 2012-04-18 08:19 doc
drwxr-xr-x 2 amira amira 4096 2012-04-18 08:19 lib
-rw-r--r-- 1 amira amira 1992 2012-04-07 05:51 LICENSE.txt
-rw-r--r-- 1 amira amira 1028 2012-04-07 05:51 README
-rw-r--r-- 1 amira amira 2400 2012-04-07 05:51 RELEASE-NOTES
drwxr-xr-x 5 amira amira 4096 2012-04-18 08:19 samples
-rwxr-xr-x 1 amira amira 470 2012-05-01 09:23 settings.sh
-rwxr-xr-x 1 amira amira 470 2012-05-01 09:22 settings.sh~
drwxr-xr-x 3 amira amira 4096 2012-04-18 08:19 src
drwxr-xr-x 3 amira amira 4096 2012-04-18 08:19 test
drwxr-xr-x 2 amira amira 4096 2012-04-18 08:19 testdata
-rw-r--r-- 1 amira amira 2908 2012-04-07 05:51 third-party-license.txt
Now from this directory, issue the following command:
java -cp build iitb.Segment.Segment train -f samples/us50.conf
Another thing you could do is copying the samples folder inside your build folder (So it becomes the iitb folder's sibling), and then issuing the command from inside the build folder:
java iitb.Segment.Segment train -f samples/us50.conf
First test:
I cant'copy the samples folder inside the build folder:
amira@amira-VirtualBox:~/CRF$ java -cp build iitb.Segment.Segment train -f samples/us50.conf
Exception in thread "main" java.lang.NoClassDefFoundError: gnu/trove/set/hash/TIntHashSet
at iitb.Model.FeatureGenImpl.<init>(FeatureGenImpl.java:68)
at iitb.Model.FeatureGenImpl.<init>(FeatureGenImpl.java:213)
at iitb.Model.FeatureGenImpl.<init>(FeatureGenImpl.java:210)
at iitb.Segment.Segment.allocModel(Segment.java:161)
at iitb.Segment.Segment.train(Segment.java:256)
at iitb.Segment.Segment.main(Segment.java:65)
Caused by: java.lang.ClassNotFoundException: gnu.trove.set.hash.TIntHashSet
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
... 6 more
Second testI cant'copy the samples folder inside the build folder:
amira@amira-VirtualBox:~/CRF$ cp samples /home/amira/CRF/build
cp: omitting directory `samples'
I have the following output:Another thing you could do is copying the samples folder inside your build folder (So it becomes the iitb folder's sibling), and then issuing the command from inside the build folder:
Code:
java iitb.Segment.Segment train -f samples/us50.conf
amira@amira-VirtualBox:~/CRF/build$ java iitb.Segment.Segment train -f samples/us50.conf
Exception in thread "main" java.lang.NoClassDefFoundError: gnu/trove/set/hash/TIntHashSet
at iitb.Model.FeatureGenImpl.<init>(FeatureGenImpl.java:68)
at iitb.Model.FeatureGenImpl.<init>(FeatureGenImpl.java:213)
at iitb.Model.FeatureGenImpl.<init>(FeatureGenImpl.java:210)
at iitb.Segment.Segment.allocModel(Segment.java:161)
at iitb.Segment.Segment.train(Segment.java:256)
at iitb.Segment.Segment.main(Segment.java:65)
Caused by: java.lang.ClassNotFoundException: gnu.trove.set.hash.TIntHashSet
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
... 6 more
Which version of Java are you using? I need to know if we could use the new standards of supplying dependencies.
To know which java version you're using, please issue the following command on the terminal window:
To know which java version you're using, please issue the following command on the terminal window:
java -version
I would also like you to list the contents of the lib folder that you have in your directory.amira@amira-VirtualBox:~/CRF$ java -version
java version "1.6.0_23"
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10.2)
OpenJDK Client VM (build 20.0-b11, mixed mode, sharing)
amira@amira-VirtualBox:~/CRF$ ls -l lib
total 1552
-rw-r--r-- 1 amira amira 1090194 2012-04-07 05:52 colt.jar
-rw-r--r-- 1 amira amira 363829 2012-04-30 20:24 CRF.jar
-rw-r--r-- 1 amira amira 118412 2012-04-07 05:52 CRF-Trove_3.0.2.jar
-rw-r--r-- 1 amira amira 8709 2012-04-07 05:52 LBFGS.jar
Ok so your problem is that your settings.sh shell script is piping the different libraries of your lib folder and assigning the result to the CLASSPATH variable. The problem with this is that in shell scripts, variables do not maintain state when they're done. A workaround the problem is to pipe the resulting classpath to the terminal, but this isn't a "clean" way.
I want you to do the following:
From inside the folder where you got this output:
I want you to do the following:
From inside the folder where you got this output:
amira@amira-VirtualBox:~/CRF$ ls -all
total 72
drwxr-xr-x 9 amira amira 4096 2012-05-01 09:23 .
drwxr-xr-x 30 amira amira 4096 2012-04-24 14:32 ..
drwxrwxr-x 3 amira amira 4096 2012-04-30 20:24 build
-rw-r--r-- 1 amira amira 2223 2012-04-29 22:37 build.xml
-rw-r--r-- 1 amira amira 2231 2012-04-25 14:42 build.xml~
-rw-r--r-- 1 amira amira 2223 2012-04-07 05:52 .#build.xml.1.4
drwxr-xr-x 5 amira amira 4096 2012-04-18 08:19 doc
drwxr-xr-x 2 amira amira 4096 2012-04-18 08:19 lib
-rw-r--r-- 1 amira amira 1992 2012-04-07 05:51 LICENSE.txt
-rw-r--r-- 1 amira amira 1028 2012-04-07 05:51 README
-rw-r--r-- 1 amira amira 2400 2012-04-07 05:51 RELEASE-NOTES
drwxr-xr-x 5 amira amira 4096 2012-04-18 08:19 samples
-rwxr-xr-x 1 amira amira 470 2012-05-01 09:23 settings.sh
-rwxr-xr-x 1 amira amira 470 2012-05-01 09:22 settings.sh~
drwxr-xr-x 3 amira amira 4096 2012-04-18 08:19 src
drwxr-xr-x 3 amira amira 4096 2012-04-18 08:19 test
drwxr-xr-x 2 amira amira 4096 2012-04-18 08:19 testdata
-rw-r--r-- 1 amira amira 2908 2012-04-07 05:51 third-party-license.txt
Issue the following command:
java -cp lib/colt.jar:lib/CRF.jar:lib/CRF-Trove_3.0.2.jar:lib/LBFGS.jar:build:. iitb.Segment.Segment train -f samples/us50.conf
it's great!!
thanks a lot for your help.
thanks a lot for your help.
You're most welcome.
I do think that the best way would have been to create a small shell script that expects a parameter ( The name of the method to be triggered in your case). But if this was all what you wanted, then it's ok.
Make sure to let us know if you need anything else.
I do think that the best way would have been to create a small shell script that expects a parameter ( The name of the method to be triggered in your case). But if this was all what you wanted, then it's ok.
Make sure to let us know if you need anything else.
if it does not bother you, could you explain how to create the small shell script that expects the parameter?