After I added this dependency to my pom.xml file:
<dependency>
<groupId>com.miglayout</groupId>
<artifactId>miglayout-swing</artifactId>
<version>5.0</version>
</dependency>
I tried to import com.miglayout.*; but I got the error:
package com.miglayout does not exist
How come nothing is wrong with other libraries I have imported using Maven in the same project, but I get issues with com.miglayout?
I believe the correct package is net.miginfocom.*
The maven groupId does not always correlate with the package name.
See MigLayout Javadocs
The classes inside the MiG layout library are under the packages:
net.miginfocom.swing for the miglayout-swing artefact
net.miginfocom.layout for the miglayout-core artefact (transitive dependency of miglayout-swing).
If you are using an IDE, you should not write the imports yourself and let the IDE handle it. This way, you will avoid mistakes relating to wrong package imports. Also, you should not use import on-demand and prefer single type import.
Related
so i've been working on a Maven Project which supports JavaFX. I tried to use javafx.fxml.FXMLLoader, but i couldn't, since "FXMLLoader cannot be resolved". I tried fixing Maven dependencies (since javafx.fxml didn't showed up) but it just didn't work.
This is my main:
[4: The type javafx.fxml.FXMLLoader is not accessible
20: FXMLLoader cannot be resolved]1
Hope somebody can help me, thanks!
Referenced Libraries is for no build tools project. You use Maven, dependency is the right option instead of jars.
Add the following in pom.xml, then extension will notice you to synchronize configuration.
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>18-ea+8</version>
</dependency>
You can check the existed dependencies from Maven--> Dependencies in the left:
When using Maven with Java, is it possible to see where a dependency is used? Specifically to know which classes in your project import a class from a given dependency?
This is especially difficult when the package naming of the class and the dependency declaration's tags do not line up.
For example, given a POM which contains a dependency:
<dependency>
<groupId>org.company.project</groupId>
<artifactId>someartifact</artifactId>
<version>1.0</version>
</dependency>
find all classes that uses it (such as):
import org.company.similarprojectnamebutnotquitethesame.packagecontinued.SomeClass
TLDR: Is there an efficient way to locate all files in my project that use a given dependency?
Use a JAR search engine that matches the class name with a package, such as findjar.com or help4j.com
I want to write a FMPP Front End application but the official documentation do not explains how to include the FMPP library in a maven project, but the plugin. So i want to know how to include the library so i can extend the fmpp.setting.Settings; object.
I found it in the fmpp-maven-plugin dependencies :), so just include something like this in the dependencies' block in the pom.xml
<dependency>
<groupId>net.sourceforge.fmpp</groupId>
<artifactId>fmpp</artifactId>
<version>0.9.15</version>
</dependency>
Then use Clean and Build and try using in any java file:
import fmpp.setting.Settings;
Thats it!
How can you find which dependency to import if you just know the class name.
Imagine i am getting error
hbase/mapreduce/HbaseDBMapper.java:[9,53] package org.apache.hadoop.hbase.mapreduce.replication does not exist
This is due to fact that i dont have dependency which can give me this package.
How can i find which dependency to import from maven repository or any other website
In general, http://www.findjar.com/ can be used to find the jar files and consequent maven dependencies, given a class.
In this specific case, you may want
<artifactId>hbase-server</artifactId>
<groupId>org.apache.hbase</groupId>
as the class is defined in https://github.com/apache/hbase/tree/master/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce
I'm developing an application that will be used internally at our company. In order for it to interop with our other internal systems I have to use some maven dependencies that we use internally, but this is causing some issues with using some external 3rd party dependencies that I also need.
So essentially my pom looks like this:
<dependencies>
<dependency>
internal-framework-artifact
</dependency>
<dependency>
necessary-third-party-artifact
</dependency>
</dependencies>
I've come to find that both of these dependencies have the apache's commons-collections as one of their own dependencies (among a large number of others, but we'll just keep it at one for this question's simplicity).
If I place exclusion rules on both of them for the commons-collections pom I can compile the project, but my resulting jar won't have access to either version of commons-collections and will just result in a java.lang.NoClassDefFoundError exception. Removing the exclusion rule on either of them just results in a mvn compiler error:
[WARNING] Rule 2: org.apache.maven.plugins.enforcer.BanDuplicateClasses failed with message:
Duplicate classes found:
I've been looking through various so q/a's and I can't really seem to find something that's 100% relevant to my situation. I'm really at a loss as to how to resolve this. Am I missing something really obvious?
I've never actually used the maven-shade-plugin for shading, but I think this is the exact use case it was designed for.
Create a new project that uses the maven-shade-plugin (see: http://maven.apache.org/plugins/maven-shade-plugin/) to produce an uber-jar version of internal-framework-artifact which contains that classes in internal-framework-artifact and all its dependencies. Configure the plugin so that it relocates all the classes that are also dependencies of necessary-third-party-artifact to some non-conflicting package names. This new project should produce a .jar with a different name, something like internal-framework-artifact-with-dependencies.
Now modify your original pom so that it is dependent on internal-framework-artifact-with-dependencies instead, and it should work.