How to call an XML file when Java jar file is excuted

autoD

I need to save my XML file in the same location where my Java file is present and call and use the XML when java file is executed. Is there any way through which this can be achieved?

Following is my code:

File fXmlFile = new File("C:\testing eclipsefolder/workspace/java1`/bin/diliya123/v1.xml");

Here I need to specify the file path of my XML. But I don't want to give that path, it should be such that when i give my jar file to others it shouldn't change its path should be constant every time.

When I try to run the same script using the above code I get the following type of error:

[TestNG] Running:
  C:\Documents and Settings\saalam\Local Settings\Temp\testng-eclipse-1407458964\testng-customsuite.xml

Guys please suggest me someways through which it is possible.

uoyilmaz

Try using a relative path instead of an absolute path, like below:

File fXmlFile = new File("bin/diliya123/v1.xml");

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Java - How to replace a running jar file

From Java

How to convert all .class files into .java file from a .jar file

From Java

How to convert a .java or a .jar file into a Linux executable file ( without a .jar extension, which means it's not a .jar file )

From Java

How do I read a resource file from a Java jar file?

From Java

Java creating .jar file

From Java

eclipse: how to debug a Java program as a .jar file?

From Java

How to get a path to a resource in a Java JAR file

From Java

How to call method in jar file with terminal?

From Java

How can i run a .jar file in java

From Java

Java Applet in JAR File

From Java

How to read an XML file with Java?

From Java

java.io.IOException: Stream closed, when trying to access an XML file from JAR

From Java

How to tell Java the correct file path in a JAR-file?

From Java

How to add a dependency into a jar file in java

From Java

How to call BeanFactoryPostProcessor.postProcessBeanFactory method when use Spring with XML configuration file?

From Dev

Java - how to use forever tool for the jar file?

From Dev

How to rewrite xml file in Java

From Dev

How to avoid reading of DTD when parsing XML file in Java?

From Dev

How to create windows service from jar file and how to call it from another jar file?

From Dev

How to parse an XML file java

From Dev

How do I open a jar file with java?

From Dev

Jar file as agent in java

From Dev

Java properties file in jar not found when running jar

From Dev

Java jar file not running

From Dev

How to execute the jar file from a java class

From Dev

Java: Open xml-File inside a Jar. Not able to open it

From Dev

How to make the Java to call a String from a XML file(In Android Studio)

From Dev

Selenium c# How to stop the . exe file after the test was excuted

From Dev

How to package a .jar file using a java program

Related Related

  1. 1

    Java - How to replace a running jar file

  2. 2

    How to convert all .class files into .java file from a .jar file

  3. 3

    How to convert a .java or a .jar file into a Linux executable file ( without a .jar extension, which means it's not a .jar file )

  4. 4

    How do I read a resource file from a Java jar file?

  5. 5

    Java creating .jar file

  6. 6

    eclipse: how to debug a Java program as a .jar file?

  7. 7

    How to get a path to a resource in a Java JAR file

  8. 8

    How to call method in jar file with terminal?

  9. 9

    How can i run a .jar file in java

  10. 10

    Java Applet in JAR File

  11. 11

    How to read an XML file with Java?

  12. 12

    java.io.IOException: Stream closed, when trying to access an XML file from JAR

  13. 13

    How to tell Java the correct file path in a JAR-file?

  14. 14

    How to add a dependency into a jar file in java

  15. 15

    How to call BeanFactoryPostProcessor.postProcessBeanFactory method when use Spring with XML configuration file?

  16. 16

    Java - how to use forever tool for the jar file?

  17. 17

    How to rewrite xml file in Java

  18. 18

    How to avoid reading of DTD when parsing XML file in Java?

  19. 19

    How to create windows service from jar file and how to call it from another jar file?

  20. 20

    How to parse an XML file java

  21. 21

    How do I open a jar file with java?

  22. 22

    Jar file as agent in java

  23. 23

    Java properties file in jar not found when running jar

  24. 24

    Java jar file not running

  25. 25

    How to execute the jar file from a java class

  26. 26

    Java: Open xml-File inside a Jar. Not able to open it

  27. 27

    How to make the Java to call a String from a XML file(In Android Studio)

  28. 28

    Selenium c# How to stop the . exe file after the test was excuted

  29. 29

    How to package a .jar file using a java program

HotTag

Archive