0

I want to make relative path for my jasper reports but unsuccessful:

String REPORT="C:\\Users\\Muhammad Awais\\Documents\\NetBeansProjects\\BILLING\\src\\billing\\MyReports\\report.jrxml";
String rel="BILLING\\src\\billing\\MyReports\\report.jrxml";
Alex K
  • 22,315
  • 19
  • 108
  • 236

1 Answers1

0

You need to make use of the fact that current working directory is represented by . operator. In relative path, everything else is relative to it. Similar to

String relativePath=".\\BILLING\\src\\billing\\MyReports\\report.jrxml";

You can refer to the Java Path operations documentation here. You can also use toRealPath() to get the absolute path of a relative path.

The toRealPath method returns the real path of an existing file. This method performs several operations in one:

  • If true is passed to this method and the file system supports symbolic links, this method resolves any symbolic links in the path.
  • If the Path is relative, it returns an absolute path.
  • If the Path contains any redundant elements, it returns a path with those elements removed.
Community
  • 1
  • 1
ruth
  • 29,535
  • 4
  • 30
  • 57