I'm fairly new to Java and I can't figure out how to properly call classes from another projects using Maven to do something like this:
import AnotherProjectClass; public class Jade { public void exampleFunction(){ AnotherProjectClass apc = new AnotherProjectClass(); apc.smth(); } } I'm using NetBeans and have three projects. Two of them are Web applications (as seen here Web Applications) and the main one is a Java application, all with Maven.
In both Web Applications I have used the maven-war-plugin to build the .jar file when building the .war file. Following the answer: https://stackoverflow.com/a/31220514
Next I added both .jar files as dependencies to the main Java application project following these answers: https://stackoverflow.com/a/21340440 and https://stackoverflow.com/a/48452297
I can successfully build the main project, but I can't call anything from the other two projects, although they appear in the dependencies tab. Dependencies from main project
My pom.xml from the main project (maven_tese_lima) is like this:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.limatese</groupId> <artifactId>maven_tese_lima</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <dependencies> <dependency> <groupId>com.tilab.jade</groupId> <artifactId>jade</artifactId> <version>4.3.3</version> <type>jar</type> </dependency> <dependency> <groupId>edu.stanford.protege</groupId> <artifactId>org.protege.editor.owl.codegeneration</artifactId> <version>1.0.2</version> <type>jar</type> </dependency> <dependency> <groupId>com.limatese</groupId> <artifactId>tese_maven_REST_nextstep</artifactId> <version>1.0-SNAPSHOT</version> <classifier>classes</classifier> </dependency> <dependency> <groupId>com.limatese</groupId> <artifactId>tese_maven_REST_state</artifactId> <version>1.0-SNAPSHOT</version> <classifier>classes</classifier> </dependency> </dependencies> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> </project>
commonJAR as separate project and use it as dependency in the other projects.