Netbeans/java: Could not find or load main class l

2019-07-21 04:46发布

问题:

I'm trying to setup my development environment on Linux Mint after an unfortunate reinstall of my whole computer due to some windows troubles. For the development of the Java program I use Netbeans. I allready installed all dependencies and external libraries. However when I'm trying to run the program I get the following output:

ant -f /home/***/Documents/ebart/git/projecten/nedap/Next -Dnb.internal.action.name=run run
init:
Deleting: /home/***/Documents/ebart/git/projecten/nedap/Next/build/built-jar.properties
deps-jar:
Updating property file: /home/***/Documents/ebart/git/projecten/nedap/Next/build/built-jar.properties
compile:
run:
Error: Could not find or load main class library
Java Result: 1 
BUILD SUCCESSFUL (total time: 0 seconds)

I already tried to make it work with openJDK, orcacle(normal) JDK, Ubuntu 15.04, Linux Mint, Netbeans 8.0.2, Netbeans 7.0...?1 or 2? but it doesn't make a difference. Also google couldn't provide me with a solution.

The strange thing is that my main class is called "Next" and I'm fairly sure that I selected the right Main Class (com.bata.ebart.next.Next). I suppose it has something to do with that java cannot find its main libraries(http://en.wikipedia.org/wiki/Java_Class_Library) but I'm not sure about that. Also I am not into that and therefore I have no clue what to do.

Does someone know how to solve this issue or help me in the right direction?

回答1:

Right click project in Projects. Select Properties. In the Categories select Run. For the Main Class option click browse and select the correct Main Class. Then try rebuilding your project and running it.



回答2:

And the solution lays in a VM Options. I already added the VM Option -Djava library path="/usr/lib/jni/" to make librxtx-java work (according to this post). Removing this VM Options fixed my problem. I haven't tested if I still can connect to my serial device (the reason why I'm using librxtx-java) because I don't have my serial device over here.