在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Java  網(wǎng)絡安全/ 使用ZXing生成二維碼,識別JVM版本的時候出錯?

使用ZXing生成二維碼,識別JVM版本的時候出錯?

各位前輩,我使用谷歌的ZXing創(chuàng)建二維碼,按照網(wǎng)上的例子寫。剛開始可以運行,然后我在其他Service里面打了個斷點,調(diào)試了一下其他問題,再運行這個地方就報錯了。
例子:

        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么,應該如何修改?為什么之前可以運行?
請各位前輩指導。

回答
編輯回答
膽怯

請問一下你用的ZXing是哪個版本,具體是用了哪個幾個模塊???

2018年9月20日 00:34
編輯回答
乖乖瀦

問題解決了,ZXing只能識別1.X這種形式的java版本,我的是9.0.X形式的,要System.setProperty("java.specification.version","1.9")就可以運行了

2017年11月13日 19:09