Jump to content
We've recently updated our Privacy Statement, available here ×

Compile report in java 1.4


aguth

Recommended Posts

I am having trouble compiling a jasper report to run on java 1.4. 

The exception I get shows that it is looking for a method in the String class that was introduced in Java 1.5.  Is there a workaround?  I don't have the option of upgrading my jvm.


java.lang.NoSuchMethodError: java.lang.String.replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;

 

I am using ant with a jdk 1.4 as my JAVA_HOME. 

I have tried to specify a different compiler in my ant task, but it doesn't seem to make a difference.  I get the same result regardless of whether or not I use the compiler attribute in the jrc task.   (Not I tried using the JRJdk13Compiler class since I couldn't find one for 1.4 specifically).

Here's my jrc call i my ant script (see code section)

 

Please help!  I need to get this working in 1.4.

Alan

Code:
        <jrc                compiler="net.sf.jasperreports.engine.design.JRJdk13Compiler"                destdir="${reports}">            <src>                <fileset dir="${reports}">                    <include name="**/*.jrxml"/>                </fileset>            </src>            <classpath refid="classpath.jasperReport"/>        </jrc>
Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Still not working, I tried compiling the jrxml from code and that gave the same exception.

OUTPUT:java.lang.NoSuchMethodError: java.lang.String.replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;	at net.sf.jasperreports.engine.util.JRStringUtil.escapeJavaStringLiteral(JRStringUtil.java:364)	at net.sf.jasperreports.engine.design.JRClassGenerator.generateInitParamsMethod(JRClassGenerator.java:339)	at net.sf.jasperreports.engine.design.JRClassGenerator.generateInitParamsMethod(JRClassGenerator.java:284)	at net.sf.jasperreports.engine.design.JRClassGenerator.generateClass(JRClassGenerator.java:136)	at net.sf.jasperreports.engine.design.JRClassGenerator.generateClass(JRClassGenerator.java:123)	at net.sf.jasperreports.engine.design.JRAbstractClassCompiler.generateSourceCode(JRAbstractClassCompiler.java:109)	at net.sf.jasperreports.engine.design.JRAbstractCompiler.createCompileUnit(JRAbstractCompiler.java:271)	at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:168)	at Test.main(Test.java:23)	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)	at java.lang.reflect.Method.invoke(Method.java:324)	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

 

Code:


Post Edited by aguth at 05/15/2009 21:17
Link to comment
Share on other sites

I have the same problem in my JRE1.4.2 environment. I figured that two classes in JasperReports V3.5.x have dependencies to Java 1.5.

net.sf.jasperreports.engine.fill.DefaultChartTheme 
net.sf.jasperreports.engine.util.JRStringUtil

I am not sure what to do about it? I also do not have the option to upgrade to Java 1.5.

However in the documentation it is said that JasperReports runs in a JRE1.4.2 environment. Isn't that true anymore?

Regards.

 

 

 

 

 

Link to comment
Share on other sites

You need to rewrite methods escapeJavaStringLiteral in net.sf.jasperreports.engine.util.JRStringUtil and createDialChart in net.sf.jasperreports.engine.fill.DefaultChartTheme to eliminate usage of 1.5's methods String.replace and Boolean.parseBoolean

After that recompile jasperreports project using 1.4 jdk

Link to comment
Share on other sites

That's great but looks like you'll need to use the SVN code since the fix isn't released yet. 

I have also gotten it working another way.  Compiling with JDK1.5 but using the net.sf.jasperreports.engine.design.JRJdtCompiler compiler class instead.  Seems to compile fine and then run in JDK1.4 on my server.

There's mention in the docs about using a jasperreports.properties file.  Mine seems to work now with or without it, but this is something else you can try if you're having a similar problem:

(jasperreports.properties)

org.eclipse.jdt.core.compiler.source=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.codegen.TargetPlatform=1.2

Code:
        <jrc compiler="net.sf.jasperreports.engine.design.JRJdtCompiler" destdir="${reports}">            <src>                <fileset dir="${reports}">                    <include name="**/*.jrxml"/>                </fileset>            </src>            <classpath refid="classpath.jasperReport"/>        </jrc>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...