0

I'm getting the error Error: Could not find or load main class ExcelFileEditor when trying to run my program. I compiled the program with no errors by:

javac -cp C:\Users\rperera\IdeaProjects\LinkingNames\libs\*;. C:\Users\rperera\IdeaProjects\LinkingNames\src\ExcelFileEditor.java

I tried doing:

java ExcelFileEditor

java -cp C:\Users\rperera\IdeaProjects\LinkingNames\libs\* ExcelFileEditor

but I keep getting the same error. I'd really appreciate it if someone could help me fix this problem!

public static void main(String[] args) {
    //this allows the Py4J module in Python to use whichever methods it needs from this class
    ExcelFileEditor editor = new ExcelFileEditor(new File(args[0]));
    GatewayServer server = new GatewayServer(editor);
    server.start();
}

The package is excel.writer

6
  • Where is your main function ? In ExcelFileEditor class ? and also could you provide main function prototype Commented Aug 18, 2015 at 20:47
  • What package do you declare ExcelFileEditor to be in, and where does its class file end up after running javac? Commented Aug 18, 2015 at 20:48
  • Remove "C:\Users\...\*" in the -cp arg and enumerate each jar contained in the ...\lib directory; separate each jar with semicolons. I.e., -cp c:\a\b\c\first.jar;c:\a\b\c\second.jar;c:\a\b\c\third.jar Commented Aug 18, 2015 at 20:55
  • You have compiled HyperlinkWriter, why are you expecting to run ExcelFileEditor? Also, usually javac puts the compiled .class file in the same directory where the source was, so you need to add C:\Users\rperera\IdeaProjects\LinkingNames\src to the classpath. Commented Aug 18, 2015 at 21:01
  • @DannyDaglas, I can't do that since I'm using POI and there's a lot of jars Commented Aug 19, 2015 at 13:14

1 Answer 1

1

If you are not specifying where to place the generated class files then its going to be in the same directory as the source file. Try

java -classpath C:\Users\rperera\IdeaProjects\LinkingNames\libs\*;C:\Users\rperera\IdeaProjects\Li‌​nkingNames\src excel.writer.ExcelFileEditor

Sign up to request clarification or add additional context in comments.

2 Comments

The classpath still needs C:\Users\rperera\IdeaProjects\LinkingNames\libs\* in it as well.
Use -classpath. I edited the answer so that its more readable.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.