Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Null Pointer Exception

  Asked By: Fabiana    Date: Aug 26    Category: Java    Views: 751
  

I have the following file C:\de\mud\jta\Main.java.

In this file I have the following line:

final Properties options = new Properties();
options.load(Main.class.getResourceAsStream
("/de/mud/jta/sshlogin.conf"));

I have the file C:\de\mud\jta\sshlogin.conf.

But when I run the code, I get a java.lang.NullPointerException. What
am I doing wrong?

Any ideas?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Keith Marshall     Answered On: Aug 26

getResourceAsStream() returns null  if the resource cannot be found. Is the
Main.class file  in the same directory as the sshlogin.conf?

You may want to try:

Main.class.getResourceAsString("sshlogin.conf")

 
Didn't find what you were looking for? Find more on Null Pointer Exception Or get search suggestion and latest updates.




Tagged: