Amigos como eu poderia pegar o caminho da aplicacao para o relatorio ???
eu ate consegui fazer, dentro da IDE roda legal, mais quando quando compilado.. o .jar. nao consegue
mais executar...
acredito por falta de conhecimento existir algum comando ou instrucao java que faca isso;.
o meu código:public String getApplicationPath() {
//u.getApplicationPath());
String url = getClass().getResource(getClass().getSimpleName() + ".class").getPath();
File dir = new File(url).getParentFile();
String path = null;
if (dir.getPath().contains(".jar")) {
path = findJarParentPath(dir);
} else {
path = dir.getPath();
}
try {
return URLDecoder.decode(path, "UTF-8");
} catch (UnsupportedEncodingException e) {
return path.replace("%20", " ");
}
String caminho = u.getApplicationPath();
caminho = caminho.replace("\", "/")+"/rel1.jasper";
String caminho = u.getApplicationPath();
caminho = caminho.replace("\", "/")+"/rel1.jasper";
parameters.put("parametro_nome", variavel);
//JasperPrint print = JasperFillManager.fillReport("C:/Temp/teste/src/teste/rel1.jasper", parameters, conn);
//JasperPrint print = JasperFillManager.fillReport(caminho, parameters, conn);
JasperPrint print = JasperFillManager.fillReport(caminho, parameters, conn);
JasperViewer jrviewer = new JasperViewer(print, false);
jrviewer.setVisible(true);
Obrigado.