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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:06:18+00:00 2026-06-11T19:06:18+00:00

I want to access to get the string path to my resource key files.

  • 0

I want to access to get the string path to my resource key files. If I debug the project in eclipse, everything works like a charm but if I export the project to a runnable .jar file – the project can’t access the key files because the path is wrong.

PUBLIC_KEY_PATH = "src/resources/public.key";
PRIVATE_KEY_PATH = "src/resources/private.key";

But how do I get the right path for the runnable .jar file? I don’t want to get the URL or anything else – I want to get the string path.

I hope that someone can help me.


Solution:

public static String PUBLIC_KEY_PATH = "/resources/public.key";
public static String PRIVATE_KEY_PATH = "/resources/private.key";

I’m using an InputStream to read the file content:

InputStream in = ExampleClass.class.getResourceAsStream(PUBLIC_KEY_PATH);
ObjectInputStream oin = new ObjectInputStream(new BufferedReader(in));

There we go 😉

  • 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-11T19:06:19+00:00Added an answer on June 11, 2026 at 7:06 pm

    You can get an inputStream from the file via Class#getResourceAsStream(). For example:

    InputStream is = FooClass.class.getResourceAsStream("public.key");
    

    where you save public.key file in the same directory FooClass.java FooClass.class is located in.

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

Sidebar

Related Questions

i want to access or get the class which is present in different project.How
I want to get access to the data-global-id value in the following markup and
I want to to get the access token from LinkedIn. First I send the
Using Access 2003 I want to get a table value from the two databases
when I want to retrieve date from access , I get an exception error
I want to access the following path on Ubuntu in my python code: ~/.mozilla/firefox/dh4ytbdj.default/bookmarkbackups
I want to access text-shadow property just like we access padding property. Means ,
i want to know how i can test if i can access a string
I want to access a class from another project using ClassLoader. How can I
I want to make sure a file path set via query string does not

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.