Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6755875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:27:18+00:00 2026-05-26T13:27:18+00:00

I have an external library that needs to be dynamically linked with a test

  • 0

I have an external library that needs to be dynamically linked with a test in my java project. The project is setup using maven, and I need to add the following to my vm arguments in eclipse for the test to pass:

-Djava.library.path=${env_var:HOME}/.m2/repository/natives/dist/lib -ea

Unfortunately this means that running the test from maven using: mvn test will always fail.

One work around is to call mvn with a -DargLine argument like so:

mvn test -DargLine="-Djava.library.path=/Users/rob/.m2/repository/natives/dist/lib -ea"

However, clearly this has the problem of being specific to my machine, so I can’t put it directly in the pom file. I guess what I’m looking for is a way of modifying that string on a per machine basis kinda like the first line does for eclipse.

I’m also curious how I could put it into the POM file, I’ve tried placing it inside of <argLine> tags, but that doesn’t seems to work, is there something I’m missing:

<argLine>-Djava.library.path=/Users/rob/.m2/repository/natives/dist/lib -ea</argLine>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:27:18+00:00Added an answer on May 26, 2026 at 1:27 pm

    After some research I’ve discovered a decent solution to my problem.

    In maven your settings.xml file, you can define a location for the localRepository here are the defaults if you set nothing:

    • Unix/Mac OS X – ~/.m2
    • Windows – C:\Documents and Settings\username.m2

    As you can see this matches at least the first part of the directory I was trying to set: /Users/rob/.m2

    Since dynamic linking is OS specific, you may also want to setup a profile for alternate path suffixes. You can do this in a .pom like this:

    <profile>
        <id>OSX</id>
            <activation>
                <os>
                    <family>mac</family>
                </os>
            </activation>
        <properties>
            <dynamic.libLoc>${settings.localRepository}/natives/dist/lib</dynamic.libLoc>
        </properties>
    </profile>
    

    You can then use this property in the .pom for the project you wish to test. Under the plugins category you can add:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <argLine>-Djava.library.path=${dynamic.libLoc}</argLine>
        </configuration>
    </plugin>
    

    Now maven can run those tests without users having to specify the location of the dynamically linked libraries. You can also handle users with different operating systems by just adding another profile.

    Note: With regards to my problem with <argLine> earlier. I think I was just using it in the wrong .pom

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a java application and it needs linking some external library( actually jar
I have a compiled external library that I'm using in my (Objective-C++) code. This
I have a function in an external library that I cannot change with the
I have a library that does I/O. There are a couple of external knobs
I have a problem; I'm using an external library where one particular event has
I have an external library that takes an IntPtr. Is there any safe way
I'm writing a library that needs to have some code if a particular library
I have a external library that requires a XmlNode[] instead of XmlNodeList. Is there
I have written an external script that needs to run after DOM is ready
I have a C# class library that contains methods that need to be used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.