3

I have a bigger project with multiple modules, all organized by Maven and Spring.

Now I got a "closed source" JAR and two additional files (basically sth. like 2 text files with some information needed for the classes in the JAR) that I want to add to my project.

The manual that came with the JAR and the two files only says "Add the JAR as a lib" and "Add the 2 files to your classpath". I (or my IDE) already managed to add the JAR, but how and where can I add the other 2 files?

Thanks in advance, kaolick

EDIT:

As it seems one of my colleagues already added the JAR and the two files to the repository. I just didn't know about it because he called in sick this week and didn't tell me before. :-/

4 Answers 4

1

You should place the files in src/main/resources folder then they will be on the classpath. As for the jar you should add it to pom as a dependency, eg

<dependency>
        <groupId>test</groupId>
        <artifactId>myjar</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>${basedir}/lib/myjar.jar</systemPath>
</dependency>
Sign up to request clarification or add additional context in comments.

1 Comment

I guess your answer is correct so far. Just couldn't test it (see my edit above). Thanks anyway!
0

You can upload the jar file to your local repository and then reference it like a usual library within your maven configuration. You can upload the file from the command line:

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
    -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

See the documentation for more details.

1 Comment

Is there any way to do that using a UI, f.e. by using my IDE (Netbeans)? I'm a noob with the command line, and because my question is work-related I don't want to screw up things here. ;-)
0

As far as I know there's no specific way to add resource files to a project in Netbeans but it's quite legal to do it simply by copying the files into src/main/resources directory with your favourite file manager. Netbeans will recognize new files in the project straightaway and update the view.

Comments

0

I had to add the 2 *.dat files to the src/main/resources directory and the following lines to the pom.xml

<resources>
    <resource>
        <directory>src/main/resources</directory>
            <includes>
                <include>*.dat</include>
            </includes>
        </resource>
    </resources>
</resources>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.