LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-11-2006, 08:12 AM   #1
hunterfighter
Member
 
Registered: Oct 2004
Location: Malaysia, Kuala Lumpur
Distribution: FreeBSD
Posts: 65

Rep: Reputation: 15
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)
 
Old 09-11-2006, 08:17 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
You seems to run your app with a JRE while a JDK is expected.
 
Old 09-11-2006, 08:25 AM   #3
hunterfighter
Member
 
Registered: Oct 2004
Location: Malaysia, Kuala Lumpur
Distribution: FreeBSD
Posts: 65

Original Poster
Rep: Reputation: 15
How to solve this problem?
 
Old 09-11-2006, 09:28 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
By using the java command that is part of a JDK installation and not from a JRE one.
 
Old 09-11-2006, 09:30 AM   #5
hunterfighter
Member
 
Registered: Oct 2004
Location: Malaysia, Kuala Lumpur
Distribution: FreeBSD
Posts: 65

Original Poster
Rep: Reputation: 15
I am using Netbeans as my IDE. So I think it should be okie. Or maybe got some toher setting?
 
Old 09-11-2006, 09:34 AM   #6
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
And you run your code from netbeans ?

Then perhaps the issue is simply you haven't javac in your PATH.
 
Old 09-11-2006, 09:41 AM   #7
hunterfighter
Member
 
Registered: Oct 2004
Location: Malaysia, Kuala Lumpur
Distribution: FreeBSD
Posts: 65

Original Poster
Rep: Reputation: 15
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.

Last edited by hunterfighter; 09-11-2006 at 10:23 AM.
 
Old 09-11-2006, 02:39 PM   #8
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
I still believe there is a problem with your PATH. NetBeans doesn't need javac to compile, but jasper reports needs it.
 
Old 09-12-2006, 06:42 AM   #9
hunterfighter
Member
 
Registered: Oct 2004
Location: Malaysia, Kuala Lumpur
Distribution: FreeBSD
Posts: 65

Original Poster
Rep: Reputation: 15
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.
 
Old 09-12-2006, 11:18 AM   #10
tamtam
Member
 
Registered: May 2004
Distribution: Slackware.
Posts: 323

Rep: Reputation: 33
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.
 
Old 09-12-2006, 12:17 PM   #11
hunterfighter
Member
 
Registered: Oct 2004
Location: Malaysia, Kuala Lumpur
Distribution: FreeBSD
Posts: 65

Original Poster
Rep: Reputation: 15
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.
 
Old 09-12-2006, 12:34 PM   #12
tamtam
Member
 
Registered: May 2004
Distribution: Slackware.
Posts: 323

Rep: Reputation: 33
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...
 
Old 09-12-2006, 02:44 PM   #13
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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 ?
 
Old 09-12-2006, 08:51 PM   #14
hunterfighter
Member
 
Registered: Oct 2004
Location: Malaysia, Kuala Lumpur
Distribution: FreeBSD
Posts: 65

Original Poster
Rep: Reputation: 15
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
buttons - report titanium_geek LQ Suggestions & Feedback 2 04-16-2006 09:57 AM
Lire (log analysis, log report) no report in Mandriva 2005 LE (desktop usage) Emmanuel_uk Mandriva 0 01-16-2006 02:11 AM
Using Jasper Reports borgy_t Programming 5 05-12-2005 09:28 AM
about jasper and ayttm ankscorek Linux - Software 1 11-16-2004 07:59 AM
How can I report the Error Report? domeili Linux - Newbie 1 10-30-2003 05:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration