senny/emacs-eclim

Could not find or load main class org.test

Opened this issue · 3 comments

wove5 commented

Hi there.

I have installed the following on my Fedora 25 workstation:
eclipse in my home directory - after I removed the repository installation with dnf.
eclim using the "Build from Source method", -(the graphical installer did not work for me).
eclim 20170328.1807 form melpa,

Eclim is working for me in both VIM and emacs. I can create projects, build projects, perform auto-complete, run code in VIM only, but cannot run a class in emacs.

I have been trying the my_project example on http://eclim.org/gettingstarted.html
My directory layout for eclim projects is as follows:

[david@localhost my_project]$ pwd
/home/david/projects_eclim/workspace_eclim/my_project
[david@localhost my_project]$ tree
.
├── bin
│   └── org
│   └── test
│   ├── TestMain.class
│   ├── TestMain.java~
│   └── workbench.xmi
└── src
└── java
└── org
└── test
├── TestMain.java
├── TestMain.java~
└── workbench.xmi

The sample java source file TestMain.java suggested by http://eclim.org/gettingstarted.html is:

package org.test;
public class TestMain
{
public static final void main(String[] args)
{
System.out.println("Hello World");
}
}

In emacs when I try M-x eclim-run-class , I get the following error showing in the compilation buffer:

~/eclipse/eclim -command java -p my_project -c org.test.
Error: Could not find or load main class org.test.
[java] Java Result: 1

I am very new to java and programming generally. I have not used package statements before and I do not understand how the package statement at the top of the source code works, but I have found that whatever is placed between "package" and ";" gets applied as an argument to the -c option of the java command.

When I run the same command at the bash shell command line I get the same result
[david@localhost eclim]$ ~/eclipse/eclim -command java -p my_project -c org.test.
Error: Could not find or load main class org.test.
[java] Java Result: 1

However when I change this command by appending the class/source name TestMain at the end, I get:
[david@localhost eclim]$ ~/eclipse/eclim -command java -p my_project -c org.test.TestMain
Hello World

I read on some forums about the project setting called:
org.eclim.java.run.mainclass

For my projects this setting seems to always get set to "none". I tried setting it as:
org.eclim.java.run.mainclass=org.eclim.TestMain

but I still get the same error in emacs. This setting seems to have no effect.

Can anyone can help me with this?
Thank you for your time.
Regards,
David.

FYI: Development has moved to https://github.com/emacs-eclim/emacs-eclim

Does page Run configurations from the Wiki help with your problem?

wove5 commented

Yes it does, thank you nloyola; it seems the page has one small typo:
C - c C - e r r should be C - c C - e u r for 'eclim-java-run-run' ?

Thank you skybert for informing me.