Search code examples
javaintellij-ideaarduinorxtx

Intelij idea error "Could not find or load main class" when trying to add "-Djava.library.path" as vm option


I have a Windows 64 bit pc.

I'm trying to connect a Java program to my Arduino. This site says I have to use this as the command line argument: "java -Djava.library.path='RXTXcomm.jar location' 'Program name'". I am using intelij-idea as ide, so I typed "-Djava.library.path=D:\Install\Java Projects\Arduino\mfz-rxtx-2.2-20081207-win-x64" in Run configuration / VM options, "D:\Install\Java Projects\Arduino\mfz-rxtx-2.2-20081207-win-x64" being the location of RXTXcomm.jar. I also added that location to the PATH system variable, because that directory alse has the rxtxSerial.dll and rxtxParallel.dll files.

Run configuration picture: https://i.sstatic.net/utthu.png

I get the error "Error: Could not find or load main class Projects\Arduino\mfz-rxtx-2.2-20081207-win-x64". Does anyone knows how to fix this?


Solution

  • You have a space in your directory name ("Java Projects"). Try enclosing the value of the system property in quotation marks:

    -Djava.library.path="D:\Install\Java Projects\Arduino\mfz-rxtx-2.2-20081207-win-x64"
    

    If that doesn't work, put the library in a directory with no spaces in the path.