I tried troubleshooting this problem for about 4 hours. Nothing worked.
I am using Java and Intellij and JavaFX.
What do I want to do?
I have created a JavaFX programm on Windows.
I want to execute this .jar on my Raspberry Pi.
Whenever I want to execute this jar I get this error in the console:
Error: Could not find or load main class sample.Main
sample is the package and Main is my class with the main method.
The programm works JUST FINE under windows. (In and outside of IntelliJ).
What steps did I already do?
Java is up-to-date on my pi. java -version returns 1.8. So we are good here.
I have imported my used libraries (Pi4J) in my project under project-structure -> libraries. & under modules -> dependencies.
I have defined a new artifact. I set a main Class (sample.Main) & under JavaFX I set the application class to sample.Main (both are given to me by Intellij) I then build the project by going to build -> build artifacts.
I checked the MANI-FEST under /src/META-INF/MANI-FEST and it indeed has
Main-Class: sample.Main
On my pi I went to the direction in which the jar file is. Then I ran: sudo java -jar Keimgeraet.jar which should work just fine. But then I get the error.
I probably have done more but forgot it already...
What might work but I don't know how I would to that:
In other threads people mentioned that my specified paths could be wrong on another computer (in this case the pi)
Here are some pictures [imgur] how everything is set up. Maybe that helps.
I will gladly try any answer! I am not the most experienced with java and the pi but I am not a complete starter.
Sidequestion: How can I include all the libraries in one final jar file?
If you need any more details feel free to ask!
How can I create an executable JAR with dependencies using Maven?
This should solve at once your main class declaration (in archive.manifest.mainclass in the maven plugin) and your inclusion of all libraries in the final jar (this will build two JARs: pay attention to take the one "xxx-jar-with-dependencies.jar").
If it still doesn't work with this Maven plugin, let us know.
Related
The case:
I have created a complex java project (spring boot) with maven build in IntelliJ and I was able to run it, everything was working fine. Now, as IntelliJ hasn't a community edition with spring boot, I had to move to vs code. I didn't change anything in my project, I just opened the folder (which contains the pom.xml and the src folder) in vs code and let vs code load the java project (earlier I installed all the extensions like spring boot, java, etc. for vs code).
After vs code opened the project successfully, I wanted to run it in the main method by clicking the run text (I inserted the image, that you can see the folder structure):
But as stated above, I get the famous error. I reloaded the window, I cleared the workspace, I set the JAVA_HOME and CLASSPATH variables in the env variables and tried, tried, tried it again, but no success. What the hell can I do on top of that? It worked in IntelliJ, it should work in vs code too. I use java se17. Note, that if I start a new simple project, the program get's compiled and executed without any error.
Another curiosity is, if I try to load the maven dependencies, vs code says, that it can't create the dependency tree, but if I run the mvn dependency:tree command, I get all the dependencies and it says, that the build was successful.
What is going on here?
EDIT: my antivirus program blocked maven, so, the problem with the dependency tree is now gone, but the error with the classpath remains.
I'm working on a project with a couple friends and we're using vscode so that we can use git efficiently (it's for a school project so IDE is non-negotiable, don't tell me to use a different one) and we're having an issue where neither of them can run this javafx application that I've got in there for testing right now. I was having trouble running it at first and was getting the same error, but I fixed it this morning and now any javafx file I put in there will run fine for me, as long as I have the correct vmargs in the json. However, they're both getting this error when they try to run:
Error: JavaFX runtime components are missing, and are required to run this application
It doesn't say which components are missing or how to fix it which is annoying, but I'm kind of at a loss for what to do. I was having this error, then I added vmArgs to the json to load the proper modules, and it fixed the issue. One thing I've noticed is that when they try to run the file on their end, the json adds new configurations without them telling it to. Even if they delete it, it comes back. But this doesn't happen for me. What am I missing to fix this?
you can run from cmd/terminal with:
cd to ur jar directory
and run:
java -jar --module-path /path/to/javafx --add-modules=javafx.controls(or whatever jars u need from the fx lib) filename.jar
I am trying to compile and run the project
https://github.com/jitsi/jitsi-android on Eclipse by Importing.
I have imported the project successfully,Added External Jar files and Fix some of compilation errors.
When I try to run app, It is giving
Conversion to Dalvik format failed with error 1 Error on the console.So that I Clean the project, checked the all the jar files from Order and Export tab and build it again.
but it doesn't work for me.
Finally, I unchecked the all the libraries from Order and Export tab,build and run it again.
But still its giving me same error and my application is getting crashed every time i run it.
Any help will be appreciated , i really want to run this application.
here is my libs folder screenshot:-
I've had the same problem once.
Here is what I found out when I was trying to solve my issue:
The error is caused when there are two Classes/Packages with the same name (For example when LibaryX has Class org.a.b.c.Sample and LibaryY has class org.a.b.c.Sample aswell)
Different approaches which worked for some people (So if you have the error yourself, make sure to test following things out):
A) Two Libaries have the exactly same package/class-> Delete the class in one of the Libaries
B) One Jar is detected twice because it's for example in the project source folder and in the Java Build Path Libaries aswell
C) Updating Proguard often fixes it aswell (Put the new Proguard jars in [Android SDK folder]\tools\proguard\lib)
D) Cleaning the Project also helped many people (you already did that, so that won't be your solution)
When I had this issue myself it was caused because I did not follow the instructions of one of the libaries that I used. After following the libary instructions step by step, everything worked fine again.
Greetings
Felix
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?
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.
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.
I'm building an Eclipse RCP application against Eclipse 3.7.1 and Java 1.6.
I'm also using Tycho to build, and have set up my RCP according to the Tycho tutorial from the EclipseCon 2011, to which I've stuck slavishly, apart from project names.
The application builds fine up until I get to Step 5 (adding a p2 repo, then adding a .product file. Well, it still builds fine, and everything is where it should be, but I cannot start the RCP by clicking on the .exe file from the repository in the workspace.
All I get is the old dreaded "The [RCP] executable launcher was unable to locate its companion shared library" error popup.
First of all I thought I might have set up the CLASS PATH incorrectly, but when I open a console and type javaw or java -version anywhere, it all works.
Also, when I go to the pluginsfolder in the p2 repository for the RCP in the workspace, and double-click on org.eclipse.equinox.launcher_1.2.0.v20110502.jar, the RCP starts, albeit without the splash screen.
This must surely mean my Java set up is correct, and it's not a class path problem?
I'm not sure where this problem might lie (I have a plugin, a feature, a product, a repository, and a parent package with the main pom), so if you let me know your suspicions where the error might come from, I'll be more than happy to post respective XML, build.properties, screenshots and what have you. Unless this is a common error with a common solution.
Many thanks in advance!
Oh yea: Windows 7 (64-bit), JDK and JRE both 64-bit as well, Eclipse EE 3.7.1 (I chose that because it contains the most plugins I'll need later by default).
UPDATE
I'm attaching my CLASS PATH Settings for reference.
User variables
CLASS PATH: C:\Program Files\Java\jdk1.6.0_30;.;
System variables
JAVA_HOME: C:\Program Files\Java\jdk1.6.0_30
Path: %JAVA_HOME%\bin;
UPDATE 2
When I let Tycho create a ZIP file in the p2 repository, and copy that from the repo to another location, unzip it and run the .exe, the application starts without problems. So I guess this query is partially solved, but I'd still be interested to hear why I wouldn't be able to start the application from the repository...
Today I came across the same issue. I guess you could find the solution here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=176084
In short, the problem in my case was, that the org.eclipse.equinox.launcher_1.2.0.v20110502.jar must be unpacked in the plugins folder under the folder name: org.eclipse.equinox.launcher_1.2.0.v20110502
... hope that helps!
In my case the error The [RCP] executable launcher was unable to locate its companion shared library was because my path was too long.
Same issue I was facing from yesterday. Today, I have changed path of project(git clone) and build it and able to run RCP executable.
I think this issue was because of path too long.