1. 程式人生 > >linux環境下編譯不成功

linux環境下編譯不成功

[[email protected] 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
[[email protected] 01]$ ls
com  core.jar  javase.jar  META-INF  zxing_test  zxing_test.compiled.zip  zxing_test.jars.zip  zxing_test.src.zip
[[email protected] 01]$ 

我在linux環境下怎麼就是編譯不成功啊?

編碼問題我已經在努力克服了,轉utf-8,unicode都試了,無BOM也試了啊。

結果發現:

linux下注意幾點:
jdk版本一定要1.7以上,我是1.8.05;
一定要加上 -cp 引數和當前路徑;
===我的操作結果如下:
[[email protected] 01]$ java -cp *.jar:. zxing_test.Test
java -cp core.jar;javase.jar;zxing_test.jar Test param1 param2
        param1: 二維碼圖片需要包含的文字資訊
        param2: 二維碼圖片輸出路徑
[[email protected] 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
[[email protected] 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)
[[email protected] 01]$ java -cp *.jar:. zxing_test.Test aaaaaaaaaaaaaaaaaaaaaaaaaaaa a.png
成功生成二維碼