Youcefhd
Youcefhd

Reputation: 41

Importing classes from the root of external jars (.jar) in Intellij (Maven Project)

I'm using IntelliJ 2016 and I have some Maven dependencies (for ImageJ plugin development) that I added successfully, the two external libraries show up in the form of jar files . I've added them in project structure -> module -> dependencies and they show up correctly under external libraries as well, the classes show up inside them, and the dependency scope is set to compile.

One of them is being imported successfully, while the other is not. The one that works is in a sub folder in the jar

import fiji.threshold.Auto_Local_Threshold;

the other one is right under the jar and the name is not recognized when I try:

import MultipleKymograph_;

I can not change the path or declare a package for MultipleKymograph_ The dependencies are imported using POM and should be ok. I saw similar questions and I tried invalidating Intellij cache. my project is in a package that com.mycompany.imagej. I think the key here is that the specific classes that I can't access are directly in the jars.

enter image description here

Upvotes: 4

Views: 677

Answers (1)

ctrueden
ctrueden

Reputation: 6992

Just to cross-reference for anyone else who stumbles across this: the issue is that the class MultipleKymograph_ was in the default package. You cannot import classes from the default package in other code. The solution was to move it to its own package; it now lives in sc.fiji.multiKymograph.

Upvotes: 1

Related Questions