Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

NetBeans Problem (Reading Properties files)

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi

I'm facing problem while reading properties file with java program in NETBEANS IDE.The same Program is working fine in ECLIPSE IDE.How can i run this program correctly in NetBeans please help me out.The Program is give below (all files are in "propdemo" package)
----------------------------------------------------
package propdemo;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class MyProp {

private static Properties prop =null;
public static Properties loadProperties(){
InputStream in=null;
try{
if(prop==null)
{
ClassLoader cl=ClassLoader.getSystemClassLoader();
in=cl.getResourceAsStream("propdemo/prop.properties");
prop = new Properties();
prop.load(in);
}
}catch(IOException ioe){
ioe.printStackTrace();
}
return prop;
}

}
--------------------------------------------

package propdemo;

import java.util.Properties;

public class RunMe {
/**
* @param args
*/
public static void main(String[] args) {

Properties pr = MyProp.loadProperties();
System.out.println(pr.getProperty("prop2"));

}

}
---------------------------------------------------------------
& prop.properties files content

prop1=This is property 1
prop2=This is property 2
prop3=This is property 3
prop4=This is property 4
prop5=This is property 5



Thanks
bbtrip
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please don't post the same question in multiple forums. It creates duplicate conversations and wastes the time of the people trying to help you.

Thanks,
Dave
 
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!