猿问

使用 PhpJasper 创建报告时 JDK 版本出错

我尝试使用PHPJasper创建一些代码,但在同一行出现错误。我认为这是 Java SE 版本的问题。


文件hello_world.jasper已经存在于我的项目中。


源代码:


require __DIR__ . '/vendor/autoload.php';


use PHPJasper\PHPJasper;


$jasper = new PHPJasper;


$input = __DIR__ . '/vendor/geekcom/phpjasper/examples/hello_world.jasper';

$output = __DIR__ . '/vendor/geekcom/phpjasper/examples';

$options = [

    'format' => ['pdf', 'rtf']

];


$jasper->process(

    $input,

    $output,

    $options

)->execute();


var_dump($jasper);

控制台中的错误与execute():


Exception in thread "main" java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')

    at de.cenote.tools.classpath.ApplicationClasspath.add(ApplicationClasspath.java:75)

    at de.cenote.tools.classpath.ApplicationClasspath.add(ApplicationClasspath.java:65)

    at de.cenote.tools.classpath.ApplicationClasspath.addJars(ApplicationClasspath.java:134)

    at de.cenote.tools.classpath.ApplicationClasspath.addJarsRelative(ApplicationClasspath.java:151)

    at de.cenote.jasperstarter.App.processReport(App.java:178)

    at de.cenote.jasperstarter.App.main(App.java:109)

PHP Fatal error:  Uncaught PHPJasper\Exception\ErrorCommandExecutable: Your report has an error and couldn 't be processed!\ Try to output the command using the function `output();` and run it manually in the console. in /home/jack/PhpstormProjects/JasperTest/vendor/geekcom/phpjasper/src/PHPJasper.php:219

Java 版本:


java -version

openjdk version "11.0.4" 2019-07-16

OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu219.04)

OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu219.04, mixed mode, sharing)

我该如何解决?


红颜莎娜
浏览 167回答 1
1回答

catspeake

我有这个问题的解决方案。我删除了所有 java 包 ( sudo apt-get remove openjdk...) 并使用 Java JDK 1.8 版本再次安装(ubuntu 说明)在此之后我得到了正确的Java版本:java -version java version "1.8.0_221" Java(TM) SE Runtime Environment (build 1.8.0_221-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
随时随地看视频慕课网APP

相关分类

Java
我要回答