我尝试使用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:219Java 版本:java -versionopenjdk version "11.0.4" 2019-07-16OpenJDK 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)我该如何解决?
1 回答
catspeake
TA贡献1111条经验 获得超0个赞
我有这个问题的解决方案。
我删除了所有 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)
添加回答
举报
0/150
提交
取消