本文共 4613 字,大约阅读时间需要 15 分钟。
[hadoop@hd2-single 01]$ javac -cp *.jar zxing_test/Test.java zxing_test/Test.java:12: package com.google.zxing.client.j2se does not exist import com.google.zxing.client.j2se.*; ^ warning: com/google/zxing/BarcodeFormat.class(com/google/zxing:BarcodeFormat.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. warning: com/google/zxing/BinaryBitmap.class(com/google/zxing:BinaryBitmap.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. warning: com/google/zxing/DecodeHintType.class(com/google/zxing ecodeHintType.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. warning: com/google/zxing/LuminanceSource.class(com/google/zxing:LuminanceSource.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. warning: com/google/zxing/MultiFormatReader.class(com/google/zxing:MultiFormatReader.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. warning: com/google/zxing/MultiFormatWriter.class(com/google/zxing:MultiFormatWriter.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. warning: com/google/zxing/Reader.class(com/google/zxing:Reader.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. warning: com/google/zxing/ReaderException.class(com/google/zxing:ReaderException.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. warning: com/google/zxing/Result.class(com/google/zxing:Result.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. warning: com/google/zxing/common/BitMatrix.class(com/google/zxing/common:BitMatrix.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. warning: com/google/zxing/common/HybridBinarizer.class(com/google/zxing/common:HybridBinarizer.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. error: Class names, 'javase.jar', are only accepted if annotation processing is explicitly requested zxing_test/Test.java:38: cannot find symbol symbol : variable MatrixToImageWriter location: class zxing_test.Test MatrixToImageWriter.writeToFile(byteMatrix, "png", file); ^ zxing_test/Test.java:57: cannot find symbol symbol : class BufferedImageLuminanceSource location: class zxing_test.Test LuminanceSource source = new BufferedImageLuminanceSource(image); ^ warning: com/google/zxing/common/GlobalHistogramBinarizer.class(com/google/zxing/common:GlobalHistogramBinarizer.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. warning: com/google/zxing/Binarizer.class(com/google/zxing:Binarizer.class): major version 51 is newer than 50, the highest major version supported by this compiler. It is recommended that the compiler be upgraded. Note: zxing_test/Test.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 4 errors 13 warnings [hadoop@hd2-single 01]$ ls com core.jar javase.jar META-INF zxing_test zxing_test.compiled.zip zxing_test.jars.zip zxing_test.src.zip [hadoop@hd2-single 01]$ 我在linux环境下怎么就是编译不成功啊? 编码问题我已经在努力克服了,转utf-8,unicode都试了,无BOM也试了啊。
结果发现:
linux下注意几点:
jdk版本一定要1.7以上,我是1.8.05;
一定要加上 -cp 参数和当前路径;
===我的操作结果如下:
[hadoop@hd2-single 01]$ java -cp *.jar:. zxing_test.Test
java -cp core.jar;javase.jar;zxing_test.jar Test param1 param2
param1: 二维码图片需要包含的文字信息
param2: 二维码图片输出路径
[hadoop@hd2-single 01]$ ls
a.png com core.jar javase.jar META-INF zxing_test zxing_test.compiled.zip zxing_test.jar zxing_test.jars.zip zxing_test.src.zip
[hadoop@hd2-single 01]$ java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
[hadoop@hd2-single 01]$ java -cp *.jar:. zxing_test.Test aaaaaaaaaaaaaaaaaaaaaaaaaaaa a.png
成功生成二维码
转载地址:http://bfici.baihongyu.com/