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 7057545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:59:56+00:00 2026-05-28T03:59:56+00:00

I have a products.jar file. Inside that there is one class com.ClassA . The

  • 0

I have a products.jar file. Inside that there is one class com.ClassA. The structure of the project is like

products
    |--test
        |--com
            |--ClassA.java
        |--dependencies
            |---inputs.txt

Inside eclipse, ClassA.java is accessing the inputs.txt file by the following path and it is working fine

private static final String PROPERTIES_FILE_PATH = "test/dependencies/inputs.txt";

test package is in the java build path -> sources

But when I am exporting this project as products.jar, I find that in the jar file there is no test directory. There are two dirs com and dependencies at the root of the jar file. So when I am trying to execute the ClassA (residing in jar file) through command line, I am getting the following exception:

JUnit version 4.8.2
java.io.FileNotFoundException: test/dependencies/inputs.txt (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:137)
at java.io.FileInputStream.<init>(FileInputStream.java:96)

So after finding that test dir is not being exported in jar file, I changed the path of the file in my ClassA.java to dependencies/inputs.txt. It didn’t work in eclipse but I thought that it would work in jar because jar file is in classpath and dependencies folder is at the root of the jar file so the java launcher will be able to locate the dependencies folder and then inputs.txt file.

But unfortunately it is also not working.

  • 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-28T03:59:57+00:00Added an answer on May 28, 2026 at 3:59 am

    You can’t use FileInputStream to read a file packed inside a JAR – it’s not a file any more. FileInputStream only works for actual disk files.

    You need to read the resource using Class.getResourceAsStream (javadoc), e.g.

    InputStream stream = getClass().getResourceAsStream("/dependencies/inputs.txt");
    

    You leave off the test prefix because it’s not in the JAR file structure.

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

Sidebar

Related Questions

I have a Products:List<Product> class. I'd like to make it so that every time
I have a product that contains a Jar file in its distribution and I
I have a jar file I produced from compiled class files using an ant
I have a products table that contains a FK for a category, the Categories
I have some products that belongs to the some category. Each category can have
So say I have a products table with a list of products, and one
Assume you have five products, and all of them use one or more of
What source control products have a diff facility that ignores white space, braces, etc.,
I have a project that uses a third party library in the form of
I have begun working on a project that, at the moment, produces a monolithic

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.