nV News Forums


nV News Forums (http://www.nvnews.net/vbulletin/index.php)
-   Software Development (http://www.nvnews.net/vbulletin/forumdisplay.php?f=53)
-   -   Anyone know java properties? (http://www.nvnews.net/vbulletin/showthread.php?t=99862)

jcrox 10-07-07 09:48 AM

Anyone know java properties?
I need to output to the console the contents of a properties file and I'm lost... please help!!!

Heres my code so far:

package java112.labs2;

import java.util.*;
import java.io.*;

public class LabTwoThree {

private Properties props;
private String propsFile;

public void run(String propsFile) {

this.propsFile = propsFile;
What do I put in here to get the info in the properties file to output to the console?

public void loadProps() {
props = new Properties();
try {
props.load(this.getClass().getResourceAsStream(pro psFile));
catch(IOException ioe) {
System.out.println("Can't load the properties file");
catch(Exception e) {
System.out.println("Problem: " + e);

public static void main(String[] args) {
LabTwoThree go = new LabTwoThree();


jcrox 10-07-07 01:31 PM

Re: Anyone know java properties?

heres my set up:

- classes
- config
- data
- docs
- output
- public_html
- src
--- java112

Ok, with the program in the above post I need to read the information from the labs2-3.properties file located in the config folder.... I can get it to compile just fine but no matter what I do I get a NullPointerException :(
Here's the .bat file I'm using to try and run this... hopefully some java guru can help me

"C:\Program Files\java\jdk1.6.0_02\bin\java.exe" -classpath classes;config java112.labs2.LabTwoThree "config/lab2-3.properties"

jcrox 10-07-07 02:53 PM

Re: Anyone know java properties?
it works now :D

All times are GMT -5. The time now is 07:55 AM.

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.