Reputation: 41
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.
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");
}
}
Upvotes: 3
Views: 4002
Reputation: 231
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:
D:\Project\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
Go to system properties
Click on advanced system settings
Click on environment variables
Upvotes: 1
Reputation: 4820
If using Eclipse, follow https://stackoverflow.com/a/3280384/3940047 for instructions. This library has other dependencies that need to be imported - ensure you've done that.
com.github.virtuald » curvesapi
org.apache.poi » poi
org.apache.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.
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.
Upvotes: 1