根据下方链接下载Barcode4J解压包
http://xiazai.sogou.com/detail/34/0/989473006711190791.html?e=1970
解压Barcode4J,然后将文件夹内lib目录下的avalon-framework-4.2.0.jarcommons-cli-1.0.jar和build目录下的barcode4j.jar导入项目下的lib中
具体代码
package com.ningjie;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.krysalis.barcode4j.impl.code39.Code39Bean;
import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider;
import org.krysalis.barcode4j.tools.UnitConv;
public class Test {
public static void main(String[] args) {
String msg =