Exceptions and non-static methods

Hi folks,

I'm trying to read a text file from a jar but having a few problems.

My code looks like this

import java.lang.Class.*;

import java.io.*;

publicclass test

{

publicstaticvoid main(String[] args)

{

String result="";

result = getInfo("info.txt");

System.out.println(result);

}

public String getInfo(String fileName)

{

InputStream is = getClass().getResourceAsStream("info.txt");

int temp=0;

char data;

String inforesult ="";

try{

//code to read from inputstream goes here

//removed for forum post

}catch (IOException ioex){

System.out.println("Error reading file.");

}

return inforesult;

}

}

This is really only test code - I intend to rework it into another (functioning) program which currently reads the file from outside the jar.

The problem breaks down as follows:

If I leave thestatic

before main it won't compile - I get non-static method ... cannot be referenced from static context

And if I leave it out, it compiles but doesn't run:

(Exception in thread "main" java.lang.NoSuchMethodError: main)

Any thoughts on what to do?

With thanks in advance,

Conor

[2213 byte] By [C_Heeneya] at [2007-10-3 3:47:09]
# 1
Please, stop, the number of replies is overwhelming.So, nevermind. I figured it out for myself. Good work everybody who knew theanswer but didn't reply, I hope to return the favour some day.
C_Heeneya at 2007-7-14 21:44:03 > top of Java-index,Developer Tools,Java Compiler...