为了账号安全,请及时绑定邮箱和手机立即绑定

使用ZXing生成二维码,识别JVM版本的时候出错?

使用ZXing生成二维码,识别JVM版本的时候出错?

繁星点点滴滴 2019-02-21 12:35:20
各位前辈,我使用谷歌的ZXing创建二维码,按照网上的例子写。刚开始可以运行,然后我在其他Service里面打了个断点,调试了一下其他问题,再运行这个地方就报错了。例子: BitMatrix matrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE,width,height,hints); Path file = new File("C:/Users/Administrator/Desktop/SpringBoot/img.png").toPath(); MatrixToImageWriter.writeToPath(matrix,format,file); 错误信息出在这一步: MatrixToImageWriter.writeToPath(matrix,format,file); 报错信息是:Caught and handled this exception :java.lang.NumberFormatException: For input string: "" at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.base/java.lang.Integer.parseInt(Integer.java:662) at java.base/java.lang.Integer.parseInt(Integer.java:770) at com.github.jaiimageio.impl.common.ImageUtil.processOnRegistration(ImageUtil.java:1401) at com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi.onRegistration(BMPImageReaderSpi.java:97) at java.desktop/javax.imageio.spi.SubRegistry.registerServiceProvider(ServiceRegistry.java:788) at java.desktop/javax.imageio.spi.ServiceRegistry.registerServiceProvider(ServiceRegistry.java:330) at java.desktop/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:212) at java.desktop/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:136) at java.desktop/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:157) at java.desktop/javax.imageio.ImageIO.<clinit>(ImageIO.java:66) at com.google.zxing.client.j2se.MatrixToImageWriter.writeToPath(MatrixToImageWriter.java:129) at com.google.zxing.client.j2se.MatrixToImageWriter.writeToPath(MatrixToImageWriter.java:100) at com.scut.originsystem.util.QRCodeUtil.createQRCode(QRCodeUtil.java:42) at com.scut.originsystem.service.QRCodeService.qRCodeWord(QRCodeService.java:162) at com.scut.originsystem.service.QRCodeService.asyncQRCodeWord(QRCodeService.java:146) at com.scut.originsystem.service.QRCodeService$$FastClassBySpringCGLIB$$a6aa6547.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.aop.interceptor.AsyncExecutionInterceptor$1.call(AsyncExecutionInterceptor.java:115) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.lang.Thread.run(Thread.java:844) 报错的源码是:String jvmVendor = System.getProperty("java.vendor"); String jvmVersionString = System.getProperty("java.specification.version"); int verIndex = jvmVersionString.indexOf("1."); jvmVersionString = jvmVersionString.substring(verIndex + 2); int jvmVersion = Integer.parseInt(jvmVersionString); 这里显示jvmVersionString为空,无法转换为int。这是API的BUG么,应该如何修改?为什么之前可以运行?请各位前辈指导。
查看完整描述

2 回答

?
Helenr

TA贡献1780条经验 获得超4个赞

问题解决了,ZXing只能识别1.X这种形式的java版本,我的是9.0.X形式的,要System.setProperty("java.specification.version","1.9")就可以运行了

查看完整回答
反对 回复 2019-03-01
?
紫衣仙女

TA贡献1839条经验 获得超15个赞

请问一下你用的ZXing是哪个版本,具体是用了哪个几个模块???

查看完整回答
反对 回复 2019-03-01
  • 2 回答
  • 0 关注
  • 494 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信