-1

I tried to execute a Java application by reading from a source file (info.properites) but I get a NullpointerExeption. I don't understand the problem.

package Org.exemple.demo;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class App 
{
    public static void main( String[] args ) throws IOException
    {
        System.out.println( "Hello World!" );
        Properties pro = new Properties();
        InputStream input = null;
        try {
            input = App.class.getResourceAsStream("/info.properties");
            pro.load(input);
        }finally{
            if (input != null){
                input.close();
        }}
        System.out.println( "Application version : " + pro.getProperty("Org.exemple.demo.version" , "?"));
    }
}
info.proerties
Org.exemple.demo.version = 1.0
Ivar
  • 6,138
  • 12
  • 49
  • 61

1 Answers1

0

Make sure your info.properties file is available in class path and use this.

input=  App.class.getClassLoader().getResourceAsStream("info.properties");
Khalid Shah
  • 3,132
  • 3
  • 20
  • 39