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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:49:40+00:00 2026-05-14T06:49:40+00:00

I have a Java project and I want to include a text file with

  • 0

I have a Java project and I want to include a text file with the executable jar. Right now the text file is in the default package.

InputFlatFile currentFile = new InputFlatFile("src/theFile.txt");

I grab the file with that line as you can see using src. However this doesn’t work with the executable jar.

How to keep this file with the executable jar, so someone using the program can just click a single icon and run the program?

  • 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-14T06:49:40+00:00Added an answer on May 14, 2026 at 6:49 am

    The base directory in the jar file is in the classpath.

    Try InputFlatFile currentFile = new InputFlatFile(“theFile.txt”);

    You are probably using an IDE and it has a src folder in it that the IDE uses for the base of the packages. When you create the jar file from the IDE it then removes the src folder and the root folder has the packages in it.

    i.e. in eclipse src/com.blah.blah once jar file is created the structure becomes com.blah.blah

    Of course I assume that InputFlatFile is properly reading the value.

    http://www.devdaily.com/blog/post/java/read-text-file-from-jar-file

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

Sidebar

Related Questions

I'm building an executable jar for a maven java project I have. It works
I have a Java project which will include a number of large SQL statements
I have a Java Project , for which I'm now creating a Web interface,
I want to include a C library in my Java project via JNI. I
I want to include a C library in my Java project via JNI. I
I have an external JAR signpost-core-1.2.1.1.jar (from http://code.google.com/p/oauth-signpost/ ), that I want to include
I have Java project that I formerly debugged using Sysdeo Launcher. Now I'd like
i have a small java project i want to build using a makefile, the
I have been working on a Java project for a class for a while
On my java project, I have a bunch of strings externalized on a messages.properties

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.