LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Jasper report on java (https://www.linuxquestions.org/questions/programming-9/jasper-report-on-java-482398/)

hunterfighter 09-11-2006 08:12 AM

Jasper report on java
 
When I try to execute the sample code. Some error occur.

Code :
Quote:

public class Main
{
public static void main(String[] args)
{
String reportSource = "./report/templates/HelloReportWorld.jrxml";
String reportDest = "./report/results/HelloReportWorld.html";

Map<String, Object> params = new HashMap<String, Object>();

try
{
JasperReport jasperReport = JasperCompileManager.compileReport(reportSource);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, new JREmptyDataSource());
JasperExportManager.exportReportToHtmlFile(jasperPrint, reportDest);
JasperViewer.viewReport(jasperPrint);
}
catch (JRException ex)
{
ex.printStackTrace();
}
}
}
Error :
Quote:

java.io.IOException: java.io.IOException: javac: not found
at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
at java.lang.Runtime.exec(Runtime.java:591)
at java.lang.Runtime.exec(Runtime.java:464)
at net.sf.jasperreports.engine.design.JRJavacCompiler.compileClasses(JRJavacCompiler.java:62)
at net.sf.jasperreports.engine.design.JRAbstractClassCompiler.compileUnits(JRAbstractClassCompiler.java :67)
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:190)
at net.sf.jasperreports.engine.design.JRDefaultCompiler.compileReport(JRDefaultCompiler.java:105)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:211)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:144)
at jasperreportsdemoapp.Main.main(Main.java:33)

jlliagre 09-11-2006 08:17 AM

You seems to run your app with a JRE while a JDK is expected.

hunterfighter 09-11-2006 08:25 AM

How to solve this problem?

jlliagre 09-11-2006 09:28 AM

By using the java command that is part of a JDK installation and not from a JRE one.

hunterfighter 09-11-2006 09:30 AM

I am using Netbeans as my IDE. So I think it should be okie. Or maybe got some toher setting?

jlliagre 09-11-2006 09:34 AM

And you run your code from netbeans ?

Then perhaps the issue is simply you haven't javac in your PATH.

hunterfighter 09-11-2006 09:41 AM

Yeah. I running all my code from netbeans. But I just face this problem in this project only. So other project is no prolem at all. I running the netbeans in my slackware. I had set the PATH. the problem still the same.

Compiling the file was no any problem. This problem occur when run the project.

jlliagre 09-11-2006 02:39 PM

I still believe there is a problem with your PATH. NetBeans doesn't need javac to compile, but jasper reports needs it.

hunterfighter 09-12-2006 06:42 AM

So I set the PATH. Output is this.

Quote:

hunterfighter@localhost:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/jdk1.5.0_07/bin::/opt/www/htdig/bin:/usr/lib/java/bin:/usr/lib/java/jre/bin:/opt/kde/bin:/usr/lib/qt/bin:/usr/share/texmf/bin:.
If I compile in the console and execute. I has no problem at all. When I execute in Netbeans. Thats the error I get.

tamtam 09-12-2006 11:18 AM

You may have two JRE's installed one along with jdk 1.5.0_07 and one here /usr/lib/java/bin:/usr/lib/java/jre/bin, Did you install the jdk seperately or install it as part of netbeans. Also before installation get rid of previous jre that may have come with the distro you are using.

the command java -version will let you know which jre installation is applied to PATH.

hunterfighter 09-12-2006 12:17 PM

I think should be a copy of JRE bundle with the distro that I using. Then I install the JDK. Then following by Netbeans.
Quote:

hunterfighter@localhost:~$ java -version
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)
From the result, it show the java is that I install seperately.

tamtam 09-12-2006 12:34 PM

okay now try the command...

/usr/lib/java/jre/bin/java -version
or it maybe
/usr/lib/java/bin/java -version

see if you get the same result as above.

As for your problem you mat have to add jasper to your classpath with netbeans...

jlliagre 09-12-2006 02:44 PM

What says "type javac" or "which javac".

How do you launch netbeans ? are you doing it from the same console where you set the PATH ?

hunterfighter 09-12-2006 08:51 PM

Dude, I know what is my problem by follow your guides. I had settle it.

So firstly, I located the java. I means the default java which come with the distro in /usr/lib/java which is link with the JRE.
I delete the link and link it with the JDK that I installed in the earlier time. And it settle my problem.

Thanks bro on your guide.


All times are GMT -5. The time now is 03:34 PM.