my jar only open files in c:

I've made an application that works correctly when I run it in eclipse. I can open every file that is in my hard drive, "my documents", "C:",....But when I make the jar file it only open files which are in "c:", not in "My Documents"What is happening?
[273 byte] By [mrraina] at [2007-11-27 4:27:21]
# 1

hi,

post your code plz.

post at least the file opening code.

the following code works (also in a jar) fine for every input file:

public static void main(String[] args) {

String file;

file = System.getProperty("INPUT_FILE");

if (file == null) {

System.out.println("Input File error");

System.exit(-1);

}

try {

BufferedReader in = new BufferedReader(new FileReader(file));

String line;

while ((line = in.readLine()) != null) {

System.out.println(line);

}

in.close();

} catch (Exception e) {

e.printStackTrace();

}

}

run command:

java -DINPUT_FILE="C:/Documents and Settings/XXX/My documents/text.txt" -jar myjar.jar

java_2006a at 2007-7-12 9:35:59 > top of Java-index,Desktop,Deploying...
# 2

Sorry for my bad explanation and thank you for answering.

I use a fileChooser, this is the code:

fc = new JFileChooser();

int returnVal = fc.showOpenDialog(MiFrame.this);

if (returnVal == JFileChooser.APPROVE_OPTION) {

File file = fc.getSelectedFile();

try {

MyClass aux = new MyClass();

aux.processFile(file);

} catch (SAXException e1) {

e1.printStackTrace();

}

}

And in MyClass the method processFile goes like this:

public void processFile(File file) throws SAXException{

try {

XMLReader parser = XMLReaderFactory.createXMLReader();

parser.setContentHandler(new MyHandler(instances));

parser.parse(file.toString());

} catch (Exception e) {

e.printStackTrace();

System.out.println("error: " + e.getMessage());

}

}

mrraina at 2007-7-12 9:35:59 > top of Java-index,Desktop,Deploying...
# 3

>public void processFile(File file) throws SAXException{

> try {

>XMLReader parser = XMLReaderFactory.createXMLReader();

>parser.setContentHandler(new MyHandler(instances));

>parser.parse(file.toString());

> } catch (Exception e) {

>e.printStackTrace();

>System.out.println("error: " + e.getMessage());

> }

>}

What's this: parser.parse(file.toString());

Try this : parser.parse(new InputSource(new FileInputStream(file)));

instead.

Hope That Helps

java_2006a at 2007-7-12 9:35:59 > top of Java-index,Desktop,Deploying...
# 4
Yes! That really worked. Very thank you!!!
mrraina at 2007-7-12 9:35:59 > top of Java-index,Desktop,Deploying...
# 5
you are welcome, so are your DUKES :)
java_2006a at 2007-7-12 9:35:59 > top of Java-index,Desktop,Deploying...