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

The Archive Base Latest Questions

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

Using the snippet below throws me a null pointer exception, but i can’t find

  • 0

Using the snippet below throws me a null pointer exception, but i can’t find the reason:

String path = ResourcesLoader.class.getResource("src/i3d/resourcesloader/libraries/lib.txt").toString();

enter image description here

Am i using the getResources wrong? I even tried to enter the full path, like “D:\Workspace…”, double backslashes, double forwardslashes but i get the exception of null pointer. The only thing i haven’t tried is using java’s path separator, but that shouldn’t be a problem at this moment as it runs on Windows. What do i miss?

Thanks!

  • 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-30T21:49:15+00:00Added an answer on May 30, 2026 at 9:49 pm

    getResource searches via the classloader, so typically and simplified in the classpath. The src folder is not in the classpath – it only exists for the build. Depending on your build system (ANT, Maven, IDE internal) a resources folder may be merged into the classpath. You put your resource directly into the source folder which will also work (if the build process copies all non-Java resources to the class output folder or if the source folder is used for the output of the generated classes).

    / is the root for your resources if you use absolute resource locations. It is equivalent to the root within the src folder. /i3d/resourcesloader/libraries/lib.txt would be the correct way to access the resource.

    It would be nicer to separate the resources in a separate folder that is merged by the build tool (e.g. in Maven: /src/main/java, /src/main/resources).

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

Sidebar

Related Questions

I am using this snippet below, how can i add a second equal statement
Using the snippet below which uses NLog how can this be done using Enterprise
I'm using JOptionPane.showMessageDialog(null,e,Invalid Name,JOptionPane.ERROR_MESSAGE) method to display the exception extended from Exception class. But
I am using the code snippet below, however it's not working quite as I
I'm using e4x to generate a HTML-snippet for my users which they can copy
Currently I'm using the below snippet, which indent the resulting HTML by using several
I have created a tab-pane using HAML as shown in my code snippet below
Please see the snippet below and tell me how can I achieve the same
In the snippet of code below, I'm using a class to get a reference
i ran across something similar to the below code snippet, which throws a compiler

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.