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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:46:35+00:00 2026-06-12T11:46:35+00:00

I have some jar files that need to read files at startup. These files

  • 0

I have some jar files that need to read files at startup. These files are located in directories next the jar files. This is how my directory listing looks like:

code.jar
config/
       confifile.cfg

Then, in a command line prompt, I set the classpath as:

set CLASSPATH=./ext/*;./*

Then I run the program but it keeps complaining that it cannot find the “configfile.cfg”.

/config/configfile.cfg file not found!

This error comes from this code:

try {
    r = new BufferedReader(new FileReader((String)botinfilename));
    fileName=(String)botinfilename;
}
catch (FileNotFoundException e) {
    System.err.println(botinfilename + " is not found");
}

I noticed it works if I put the /config directory inside the jar file. But if I remove it and put it next to the jar it does not find the config file.

Is there some java setting trick to make this work?

EDIT 1:

I launch my program like this:

java StartProgram

  • 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-06-12T11:46:36+00:00Added an answer on June 12, 2026 at 11:46 am

    To keep it short, I just added the “-cp” JVM option. My problem was I need to add the root directory (where my jars and resources are located) to my classpath. Previously I had just added the jars with the * wildcard.

    java -cp PATH_ROOT_DIR/;PATH_TO_ROOT_DIR/*;PATH_TO_ROOT_DIR/ext/* StartProgram
    

    or you can set the class path

    set CLASSPATH=./;./ext/*;./*
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Symfony task that generates some files calls exec to a jar
I have hundreds of jar files scattered across different projects that I need to
I have some text configuration file that need to be read by my program.
I have some external configuration (XML files) that are installed in Maven. I need
I have next package structure webService.ear -- dependency.jar -- some.class Can I remove some.class
I have some resource files that are in the classpath of my web application
I have several files comprising a tomcat web application that I need to import
I have a project that includes some Java APIs, some resource files, and some
I have some data loaded as a np.ndarray and need to convert it to
I have some arbitrary pixel data that I want to save as a PNG.

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.