Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » java.io.FileNotFoundException (eclipse can not find XML file using relative path)
icon5.gif  java.io.FileNotFoundException [message #525050] Mon, 05 April 2010 11:19 Go to previous message
No real name is currently offline No real name
Messages: 2
Registered: April 2010
Junior Member
Please understand that my command of english is very poor.

I'm using 'Eclipse Java EE IDE for Web Developers'.
And Build id is '20100218-1602'

I created local server using apache-tomcat-6.0.26.

then created java source code below.

Here is my java class source.


public class JAXPTest {
public static void main(String[] args) throws Exception{
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
/* absolute path
//InputSource is = new InputSource(new FileReader("D:\\workspace\\Study\\build\\classes\\a.xml")); */
InputSource is = new InputSource(new FileReader("a.xml")); // relative path
parser.parse(is, new DefaultHandler());
}
}

When I try debugging in IDE(eclipse), the following error stack is generated. ( Of cousre, a.xml file exists in the same directory of the JAXPTest .class file.)

Exception in thread "main" java.io.FileNotFoundException: a.xml
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileReader.<init>(Unknown Source)
at JAXPTest.main(JAXPTest.java:22)

But when I used absolute path, no error was generated.
All is good.
May be the matter is relative path.


When I use java command in JDK direct, exception is not generated.

Why eclise or tomcat local server can't find a.xml file using relative path?

please teach me in very kind english.


 
Read Message icon5.gif
Read Message
Read Message
Previous Topic:Can I link a dynamic web project source and output folders to external directories ?
Next Topic:test
Goto Forum:
  


Current Time: Fri May 24 03:07:58 EDT 2013

Powered by FUDForum. Page generated in 0.01634 seconds