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

  • SEARCH
  • Home
  • 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 7682607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:36:25+00:00 2026-05-31T18:36:25+00:00

I am building a command line tool which relies on some configuration files. On

  • 0

I am building a command line tool which relies on some configuration files.

On development, I put those files under src/main/resources, and accessed by getClass().getResourceAsStream("/config-file-name"), which works well.

I choose maven-assembly-plugin to build the jar with all dependencies.

    <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.myproject.Scheduler</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
               <execution>
                   <id>make-my-jar-with-dependencies</id>
                   <phase>package</phase>
                   <goals>
                       <goal>single</goal>
                   </goals>
               </execution>
            </executions>
    </plugin>       

The configuration files are all wrapped in jar, but I want to separate them.

So, I add following config,

    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>conf.properties</include>
            </includes>
            <filtering>true</filtering>
            <excludes>
                <exclude></exclude>
            </excludes>
        <targetPath>..</targetPath>             
        </resource>
    </resources>

After done this, configuration files are along side with jar instead of wrapped in jar.

But my code can’t access the files now.

Do I need to change my way of accessing the files in code?

Or should I need to not put those files in src/main/resources/, any alternative?

If someone knows, please help.

Thanks.


Update: Finally, I give up using maven resource file, instead, I set the file path to the same path as jar by default, everything works well except Eclipse complains.

Since I want to move the config file out of jar, and don’t want it to be in target/classes folder, so I use <targetPath>..</targetPath> to move the configure file to the same directory as jar file.

When I re-generate eclipse project settings, Eclipse says: Cannot nest output folder “project/target/test-classes” inside output folder “project/target”.

Anybody help me?

  • 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-31T18:36:26+00:00Added an answer on May 31, 2026 at 6:36 pm

    I finally give up using maven resource file, set the file path to the same path as jar by default instead, everything works well except Eclipse complains.

    (Since I want to move the config file out of jar, and don’t want it to be in target/classes folder, so I use .. to move the configure file to the same directory as jar file. When I re-generate eclipse project settings, Eclipse says: Cannot nest output folder “project/target/test-classes” inside output folder “project/target”.)

    I didn’t find solution until now, seems a eclipse bug.

    Now, I give up Eclipse, and changed to IntelliJ IDEA, it’s a pretty nice IDE, especially perfectly integrated with Maven. I’ll avoid any chance to use eclipse for any maven project.

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

Sidebar

Related Questions

Is there any command line tool for Linux (FreeBSD, etc) which can modify like
I'm using this script for building application from command line: #!/bin/bash TARGET=signtest CONFIGURATION=Debug SDK=iphoneos
Is there a way to create a command line tool which will help extensively
I'm building a C++ command line tool in Xcode. The project contains dylibs for
I'm building few command-line utilities in Xcode (plain C, no Cocoa). I want all
I've been getting this undefined symbol building with this command line: $ gcc test.cpp
I have a Makefile building many C files with long long command lines and
Building the same project (without any changes) produces binary different exe-files: some small regions
I have written a command-line tool that uses sub-commands much like Mercurial, Git, Subversion
I'm in the process of building my svcutil command line to generate business objects

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.