I am trying to parse a CSV File with Coldfusion and a JavaLibrary. I found some examples but it seems that ColdFusion cannot find the Jar-File.
This is my Code:
<cfset t01= getTickCount()>
<cfscript>
fileReader = createobject("java","java.io.FileReader");
fileReader.init("C:\Dev\files.csv");
csvReader = createObject("java","au.com.bytecode.opencsv.CSVReader");
csvReader.init(fileReader, ",");
</cfscript>
<cfset t02= getTickCount()>
<cfset ArrayData = csvReader.readAll()>
<cfset t03= getTickCount()>
<cfoutput>
Process Data: #t02 - t01# ms
Display Dump: #t03 - t02# ms
<cfdump var="ArrayData"><cfabort />
</cfoutput>
and this is the ErrorMessage:
java.lang.ClassNotFoundException: au.com.bytecode.opencsv.CSVReader
at coldfusion.bootstrap.BootstrapClassLoader.loadClass(BootstrapClassLoader.java:235)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248).....more Stack blabla......
I am using the opencsv Library. The Jar File is in the following folder:
wwwroot/WEB-INF/lib
I also restarted the Server multiple times.
Thanks for your help!
au.com.bytecode.opencsv
. In newer versions the package name was switched tocom.opencsv
. You are probably using one of the newer jars, but with the old package name. Hence why it is not found. The above should solve the problem. – Alejandro