I am a beginner in java. I have downloaded a latest version of apache poi 3.16.
There are several jar files renamed and edited from old versions. i want to know how to set class path for the files in steps and what are all the jar files that need class path? I have imported all the jar files but it showed class not found exception in this code.
我是一个java初学者。我下载了最新版本的apache poi 3.16。有几个jar文件从旧版本重命名和编辑。我想知道如何为步骤中的文件设置类路径,需要类路径的jar文件有哪些?我已经导入了所有的jar文件,但是它显示了这个代码中的class not found exception。
import java.io.*;
import org.apache.poi.xssf.usermodel.*;
public class CreateWorkBook
{
public static void main(String[] args)throws Exception
{
//Create Blank workbook
XSSFWorkbook workbook = new XSSFWorkbook();
//Create file system using specific name
FileOutputStream out = new FileOutputStream(
new File("createworkbook.xlsx"));
//write operation workbook using file out object
workbook.write(out);
out.close();
System.out.println("
createworkbook.xlsx written successfully");
}
}
2 个解决方案
#1
1
Before setting the classpath for the jars create a lib folder with in your project folder and copy all the jar files in this folder. For example:
在为jar设置类路径之前,在项目文件夹中创建一个lib文件夹,并复制该文件夹中的所有jar文件。例如:
D:\Project\Java\lib
项目D:\ \ Java \ lib
After that include this location in your path.
然后在路径中包含这个位置。
For setting the path and classpath you can check this link:
要设置路径和类路径,可以检查这个链接:
https://docs.oracle.com/javase/tutorial/essential/environment/paths.html
https://docs.oracle.com/javase/tutorial/essential/environment/paths.html
For setting the path following steps:
Go to system properties
去系统属性
Click on advanced system settings
点击高级系统设置
Click on environment variables
点击环境变量
#2
0
If using Eclipse, follow https://*.com/a/3280384/3940047 for instructions. This library has other dependencies that need to be imported - ensure you've done that.
如果使用Eclipse,请按照https://*.com/a/32803384/3940047进行说明。这个库有其他需要导入的依赖项——确保您已经做到了这一点。
com.github.virtuald » curvesapi
com.github。virtuald»curvesapi
org.apache.poi » poi
表示。poi»poi
org.apache.poi » poi-ooxml-schemas
表示。poi»poi-ooxml-schemas
If using Maven, modify the pom.xml to include the poi-ooxml library. Transitive dependencies are taken care of by Maven.
如果使用Maven,请修改pom。包含poi-ooxml库的xml。传递依赖由Maven负责。
Please share exact exception trace and your environment details to help you further. I would not recommend to add the third party libraries to Java lib directory as it might add conflicts in future with other projects.
请分享准确的异常跟踪和您的环境细节,以进一步帮助您。我不建议将第三方库添加到Java lib目录中,因为它可能会在将来与其他项目发生冲突。
#1
1
Before setting the classpath for the jars create a lib folder with in your project folder and copy all the jar files in this folder. For example:
在为jar设置类路径之前,在项目文件夹中创建一个lib文件夹,并复制该文件夹中的所有jar文件。例如:
D:\Project\Java\lib
项目D:\ \ Java \ lib
After that include this location in your path.
然后在路径中包含这个位置。
For setting the path and classpath you can check this link:
要设置路径和类路径,可以检查这个链接:
https://docs.oracle.com/javase/tutorial/essential/environment/paths.html
https://docs.oracle.com/javase/tutorial/essential/environment/paths.html
For setting the path following steps:
Go to system properties
去系统属性
Click on advanced system settings
点击高级系统设置
Click on environment variables
点击环境变量
#2
0
If using Eclipse, follow https://*.com/a/3280384/3940047 for instructions. This library has other dependencies that need to be imported - ensure you've done that.
如果使用Eclipse,请按照https://*.com/a/32803384/3940047进行说明。这个库有其他需要导入的依赖项——确保您已经做到了这一点。
com.github.virtuald » curvesapi
com.github。virtuald»curvesapi
org.apache.poi » poi
表示。poi»poi
org.apache.poi » poi-ooxml-schemas
表示。poi»poi-ooxml-schemas
If using Maven, modify the pom.xml to include the poi-ooxml library. Transitive dependencies are taken care of by Maven.
如果使用Maven,请修改pom。包含poi-ooxml库的xml。传递依赖由Maven负责。
Please share exact exception trace and your environment details to help you further. I would not recommend to add the third party libraries to Java lib directory as it might add conflicts in future with other projects.
请分享准确的异常跟踪和您的环境细节,以进一步帮助您。我不建议将第三方库添加到Java lib目录中,因为它可能会在将来与其他项目发生冲突。