I've seen this question asked a lot, and I did check the other ones, and none of the responses seem to match my issue.
I'm new to Java so I probably did something stupid. I'm using Eclipse Juno Service Release 2 on CentOS 6.4 and OpenJDK 1.7.
I created a Java Project, then a package "spi_qa" under /src. Then I created a class called Program.java and another one TestCaseConfiguration.java. I want the entry point of the program to be Program. This is (a simplified version of) the code:
package spi_qa;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import au.com.bytecode.opencsv.*;
public class Program {
static String configDirectory = "/spi/share/QA/conf";
static String csvFile = "/spi/share/QA/csv/testcases.csv";
public static void main(String[] args) {
System.out.println("- Starting QA Test Suite -");
// Some QA stuff
System.out.println("- QA Test Suite completed -");
}
I have to run this as root (don't ask), and I can't do that from within Eclipse, so I went ahead to export the program through File>Export>Java>JAR file, selected my "spi_qa" package and all the files in there, and picked spi_qa.Program as the Main class. This exports fine. However when I run it, I get this:
[root@localhost Downloads]# java -cp . spi_qa.jar
Error: Could not find or load main class spi_qa.jar
[root@localhost Downloads]#
And I have absolutely no clue how that can be.
I checked and I have the corresponding:
[root@localhost Downloads]# java -version
java version "1.7.0_19"
OpenJDK Runtime Environment (rhel-2.3.9.1.el6_4-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
[root@localhost Downloads]#