How do I create a QR code for Zxing in Java 1.5?

Asked 1 years ago, Updated 1 years ago, 112 views

I am trying to create a QR code for Zxing in Java 1.5.

However, regardless of whether you download javase or core jar,
When running the Java program, is the following version different?An error occurs and an exception occurs.

org.apache.jasper.JasperException: Bad version number in.class file (enable to load class com.google.zxing.WriterException)

J I know Java is old, but the Linux server program that has been running for several years is
It was developed and built in Java 1.5, so I would like to use Zxing as it is.

Here is the version of Zxing jar I downloaded and tried.

javase-1.7.jar core-1.7.jar
javase-2.0.jar core-...
javase-2.1.jar core-...
javase-2.2.jar core-...
javase-2.3.0.jar core-...
javase-3.0.0.jar core-...
javase-3.0.1.jar core-...
javase-3.1.0.jar core-...
javase-3.2.0.jar core-...
javase-3.2.1.jar core-...
javase-3.3.0.jar core-...

Are there any other jars available for Java 1.5?(I looked for a download address, but I couldn't find it.)
Or how can I use Java 1.5 to create a QR code with Zxing?

By the way, the program is described as follows:

public String make_QR_code_file(String strPara_QR_code, intiPara_size)
    {
        try{
            String contents = strPara_QR_code;// QR-coded string
            BarcodeFormat format = BarcodeFormat.QR_CODE; // Specify QR code format

            int width = iPara_size; // Horizontal size of QR code
            intheight=iPara_size; // QR code vertical size

            // Generic cannot be used because different types of values are included.
            Hashtable<EncodeHintType, ErrorCorrectionLevel>hints=new Hashtable<EncodeHintType, ErrorCorrectionLevel>();;

            // Designated shift JIS to handle Japanese
//          hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");

            // Specify error recovery level
            // ErrorCorrectionLevel.L: 7% correction level
            // ErrorCorrectionLevel.M: 15% correction level
            // ErrorCorrectionLevel.Q: 25% correction level
            // ErrorCorrectionLevel.H: 30% correction level
            hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M)<

            // Class that encodes QR codes
            QRCodeWriter writer=newQRCodeWriter();

            BitMatrix bitMatrix = writer.encode (contents, format, width, height, hits);
            BufferedImage image=MatrixToImageWriter.toBufferedImage(bitMatrix);
            ImageIO.write(image, "png", new File("/usr/local/apache-tomcat-5.5.33/webapps/ROOT/api/file/qr_code_0001/barcode.png"));

// temporary return value
            return '';
        }
        catch(IOExceptione){
            e.printStackTrace();
        }
        catch(WriterExceptione){
            e.printStackTrace();
        }

        return null;
    }

java qr-code

2022-09-30 21:23

1 Answers

This exception is output because it is compiled with a higher version of Java than the running environment.

 org.apache.jasper.JasperException: Bad version number in.class file (enable to load class com.google.zxing.WriterException)

If you want to use such libraries in lower versions of Java, the solution is to compile them.

However, ZXing seems to be a prerequisite for compiling in Java 7 as of 2.3.0 (as far as Github is concerned), so it is unlikely that Java 5 will be able to compile.
Unfortunately, if you want to use ZXing, you need to set your Java environment to 7 or higher.


2022-09-30 21:23

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.