[ACCEPTED]-How can i Get file path in some java package?-java

Accepted answer
Score: 13

denemeJasper.class.getResource("reportDeneme.jasper").getPath()

If you need the path for reading the file's 5 contents, it would be simpler (and safer) to 4 use getResourceAsStream() and avoid having to deal with paths 3 entirely.

BTW, your class denemeJasper violates ubiquitous 2 Java naming standards; as a class, its name 1 should start with an uppercase letter.

Score: 0

The might be better off with a relative 4 path, but the absolute path would be:

String fullpath = "/jasper/deneme/reportDeneme.jasper";

'/' replaces 3 '.' in the package name whether the resource 2 is located in a file, a jar or by any other 1 means.

More Related questions