I haven't run Java in ages, and was hopeful to test a small CSV reader with a simple class. The CSV reader in question is this one here http://opencsv.sourceforge.net
I've create a small class named DecryptCsv, that's really just a main method that tries to create a CSVReader.
I've got the
import com.opencsv.*;
at the top, and am able to compile my file with javac -cp "./opencsv-3.6.jar" DecryptCsv.java
If I try to run it without the jar, using java DecryptCsv
it understandably crashes with:
Exception in thread "main" java.lang.NoClassDefFoundError: com/opencsv/CSVReader
If I try to set the class path when running though, I don't get what I expect. This:
java -cp ".;./opencsv-3.6.jar" DecryptCsv
Yields this:
Error: Could not find or load main class DecryptCsv
What's the proper way to run the main method in this simple class, that has this jar file requirement?
Thanks for the help!
Here's test class code:
import java.io.FileReader;
import java.io.IOException;
import com.opencsv.*;
public class DecryptCsv
{
public DecryptCsv()
{
// foo
}
public static void main(String[] args)
{
try
{
CSVReader reader = new CSVReader( new FileReader( "file.txt" ), ',');
}
catch( Exception exc )
{
}
System.out.println( "success" );
}
}
The jar can be downloaded at http://sourceforge.net/projects/opencsv/