I have checked other posts and found similar examples of adding charts. I tried writing them and found that there was still an error. The code is as follows:
private static void addBar(WordprocessingMLPackage wordPackage) throws Exception {
Chart chartPart = new Chart(new PartName("/word/charts/chart1.xml"));
CTChartSpace ch = new CTChartSpace();
CTBoolean bool = new CTBoolean();
bool.setVal(Boolean.FALSE);
ch.setDate1904(bool);
CTTextLanguageID lang = new CTTextLanguageID();
lang.setVal("en-US");
ch.setLang(lang);
CTChart chart = new CTChart();
CTPlotArea ctp = new CTPlotArea();
CTBarChart objBar ...