I’ve a -probably- stupid question. In CUBA Studio I’d like to manipulate objects comming from an extrnal JAR file.
I tried (this works in regular IDEA editor) to go to Project Structure > Librairies clicked on the “+” and browse to the JAR file.
Then I imported the JAR (the import looked successully and created a new instance of an object (Project here). Everything was fine but i got errors when compiling: error: package com.sciforma.psnext.api does not exist
Any clue ?
Thanks in advance
CUBA uses gradle as a build tool, and IDEA project is also imported from build.gradle script.
You should not add new libraries through Project Structure > Librairies window. All dependencies should be added to a build.gradle script file.
This link might help you: java - How to add local .jar file dependency to build.gradle file? - Stack Overflow
Note that it is rare nowadays for a developer to add local jar dependency. Most of open-source libraries are uploaded to public maven repositories, and attached to a project as a maven/gradle dependency.
thanks for the tips, but I’m still stuck … (I’m just starting to use CUBA).
Just for the record, the JAR comes from a software editor and is used to access data from a propriertary platform (Sciforma in that case). I’m afraid it’s not a public dependency.
However, could you please give me a little help that will boost my understanding. Let’s say that the file is xxx.jar and is stored in d:\libs.
I assume that I have to make changes in the file build.gradle. Is that correct ?
I tried to add, at the bottom, the lines:
implementation name: ‘xxx’
but it failed.
What should I have been done instead ?
Once again, thanks for your support.
I have put library catalina-jmx-remote.jar to “/home/budarov/jar” folder.
This code works for me:
“implementation” is not yet supported in CUBA, please use “compile” type instead.
Also it’s better to use backslashes in file paths everywhere in Java world, Java automatically converts them to Windows " \ " slashes when necessary.