CreateObject() with java
I have a totally newb problem. I have a written a java class to unzip files (which works JRUN's jre), but I am trying to use it with coldfusion and am unable to get coldfusion to even recognize that it is there. I have set up the classpath in administrator and ensured several times that the path is correct. The contents of the classpath field in CFAdmin is: C:\CFusionMX7\runtime\jre\lib\YP_Unzip.class I am sure I have to have something configured incorrectly. here is my code (though I am not sure that this is the problem): COLDFUSION: cfset temp = createObject(java, YP_Unzip) JAVA: import java.io.*; import java.util.zip.*; class YP_UnZip { public void Unzip (String Args[]){ int BUFFER = 2048; int i; BufferedOutputStream dest = null; FileInputStream inputfile; ZipInputStream zipfile; if (Args.length != 0){ //loop over files to be unzipped for(i=0; i Args.length; i++){ System.out.print(Unzipping : ); System.out.print(Args[i]); System.out.println(); try{ inputfile = new FileInputStream(Args[i]); zipfile = new ZipInputStream(new BufferedInputStream(inputfile)); ZipEntry entry; while ((entry = zipfile.getNextEntry()) != null){ System.out.println(Extracting : +entry); int count; byte data[] = new byte[BUFFER]; //write the back to disk FileOutputStream outputfile = new FileOutputStream(entry.getName()); dest = new BufferedOutputStream(outputfile, BUFFER); while ((count = zipfile.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, count); } dest.flush(); dest.close(); } } catch(Exception e){ e.printStackTrace(); }//end try-catch block } //end for loop }//end if (Args.length != 0) else{ //code for error handling goes here - error missing file } }//main } Any help would be greatly appreciated. Thanks, Wes ~| Create Web Applications With ColdFusion MX7 Flex 2. Build powerful, scalable RIAs. Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJS Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:275762 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: CreateObject() with java
Java classpaths sound not actually contain .class files (although .jar files are included in classpaths). Assuming your java class in not in a package (which is a Bad idea, but looks to be the case from your java code), then you need to include in the classpath the directory containing your .class file. A sort of best practice would be to create a directory somewhere called classes and then to put your .class files in there, and add that dir to the classpath. If your java classes are in a package (again, a good idea, like maybe com.wmiddeendorf), then your .class files go unto appropriate subdirs under classes (like classes/com/wmiddeendorf). Hope that helps. Mark -Original Message- From: Wes Middendorff [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 18, 2007 4:32 PM To: CF-Talk Subject: CreateObject() with java I have a totally newb problem. I have a written a java class to unzip files (which works JRUN's jre), but I am trying to use it with coldfusion and am unable to get coldfusion to even recognize that it is there. I have set up the classpath in administrator and ensured several times that the path is correct. The contents of the classpath field in CFAdmin is: C:\CFusionMX7\runtime\jre\lib\YP_Unzip.class I am sure I have to have something configured incorrectly. here is my code (though I am not sure that this is the problem): COLDFUSION: cfset temp = createObject(java, YP_Unzip) JAVA: import java.io.*; import java.util.zip.*; class YP_UnZip { public void Unzip (String Args[]){ int BUFFER = 2048; int i; BufferedOutputStream dest = null; FileInputStream inputfile; ZipInputStream zipfile; if (Args.length != 0){ //loop over files to be unzipped for(i=0; i Args.length; i++){ System.out.print(Unzipping : ); System.out.print(Args[i]); System.out.println(); try{ inputfile = new FileInputStream(Args[i]); zipfile = new ZipInputStream(new BufferedInputStream(inputfile)); ZipEntry entry; while ((entry = zipfile.getNextEntry()) != null){ System.out.println(Extracting : +entry); int count; byte data[] = new byte[BUFFER]; //write the back to disk FileOutputStream outputfile = new FileOutputStream(entry.getName()); dest = new BufferedOutputStream(outputfile, BUFFER); while ((count = zipfile.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, count); } dest.flush(); dest.close(); } } catch(Exception e){ e.printStackTrace(); }//end try-catch block } //end for loop }//end if (Args.length != 0) else{ //code for error handling goes here - error missing file } }//main } Any help would be greatly appreciated. Thanks, Wes ~| ColdFusion MX7 and Flex 2 Build sales marketing dashboard RIAâs for your business. Upgrade now http://www.adobe.com/products/coldfusion/flex2?sdid=RVJT Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:275765 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: CreateObject() with java
Java classpaths sound not actually contain .class files (although .jar files are included in classpaths). Assuming your java class in not in a package (which is a Bad idea, but looks to be the case from your java code), then you need to include in the classpath the directory containing your .class file. A sort of best practice would be to create a directory somewhere called classes and then to put your .class files in there, and add that dir to the classpath. If your java classes are in a package (again, a good idea, like maybe com.wmiddeendorf), then your .class files go unto appropriate subdirs under classes (like classes/com/wmiddeendorf). Hope that helps. Mark -Original Message- From: Wes Middendorff [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 18, 2007 4:32 PM To: CF-Talk Subject: CreateObject() with java I have a totally newb problem. I have a written a java class to unzip files (which works JRUN's jre), but I am trying to use it with coldfusion and am unable to get coldfusion to even recognize that it is there. I have set up the classpath in administrator and ensured several times that the path is correct. The contents of the classpath field in CFAdmin is: C:\CFusionMX7\runtime\jre\lib\YP_Unzip.class I am sure I have to have something configured incorrectly. here is my code (though I am not sure that this is the problem): COLDFUSION: cfset temp = createObject(java, YP_Unzip) JAVA: import java.io.*; import java.util.zip.*; ~| Upgrade to Adobe ColdFusion MX7 The most significant release in over 10 years. Upgrade see new features. http://www.adobe.com/products/coldfusion?sdid=RVJR Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:275766 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CreateObject() with java
That helps a little, I am now getting some other error that is not so helpfull... Object Instantiation Exception. An exception occurred when instantiating a java object. The cause of this exception was that: YP_Unzip (wrong name: YP_UnZip). This shouldn't be so difficult. On 4/18/07, Gaulin, Mark [EMAIL PROTECTED] wrote: Java classpaths sound not actually contain .class files (although .jar files are included in classpaths). Assuming your java class in not in a package (which is a Bad idea, but looks to be the case from your java code), then you need to include in the classpath the directory containing your .class file. A sort of best practice would be to create a directory somewhere called classes and then to put your .class files in there, and add that dir to the classpath. If your java classes are in a package (again, a good idea, like maybe com.wmiddeendorf), then your .class files go unto appropriate subdirs under classes (like classes/com/wmiddeendorf). Hope that helps. Mark -Original Message- From: Wes Middendorff [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 18, 2007 4:32 PM To: CF-Talk Subject: CreateObject() with java I have a totally newb problem. I have a written a java class to unzip files (which works JRUN's jre), but I am trying to use it with coldfusion and am unable to get coldfusion to even recognize that it is there. I have set up the classpath in administrator and ensured several times that the path is correct. The contents of the classpath field in CFAdmin is: C:\CFusionMX7\runtime\jre\lib\YP_Unzip.class I am sure I have to have something configured incorrectly. here is my code (though I am not sure that this is the problem): COLDFUSION: cfset temp = createObject(java, YP_Unzip) JAVA: import java.io.*; import java.util.zip.*; class YP_UnZip { public void Unzip (String Args[]){ int BUFFER = 2048; int i; BufferedOutputStream dest = null; FileInputStream inputfile; ZipInputStream zipfile; if (Args.length != 0){ //loop over files to be unzipped for(i=0; i Args.length; i++){ System.out.print(Unzipping : ); System.out.print(Args[i]); System.out.println(); try{ inputfile = new FileInputStream(Args[i]); zipfile = new ZipInputStream(new BufferedInputStream(inputfile)); ZipEntry entry; while ((entry = zipfile.getNextEntry()) != null){ System.out.println(Extracting : +entry); int count; byte data[] = new byte[BUFFER]; //write the back to disk FileOutputStream outputfile = new FileOutputStream(entry.getName()); dest = new BufferedOutputStream(outputfile, BUFFER); while ((count = zipfile.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, count); } dest.flush(); dest.close(); } } catch(Exception e){ e.printStackTrace(); }//end try-catch block } //end for loop }//end if (Args.length != 0) else{ //code for error handling goes here - error missing file } }//main } Any help would be greatly appreciated. Thanks, Wes ~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 MX7 integration create powerful cross-platform RIAs http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJQ Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:275768 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: CreateObject() with java
The class name in your CreateObject call does not EXACTLY match the class itself. Fix that and you should be better. Mark -Original Message- From: Wesley Middendorff [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 18, 2007 5:08 PM To: CF-Talk Subject: Re: CreateObject() with java That helps a little, I am now getting some other error that is not so helpfull... . Object Instantiation Exception. An exception occurred when instantiating a java object. The cause of this exception was that: YP_Unzip (wrong name: YP_UnZip). This shouldn't be so difficult. On 4/18/07, Gaulin, Mark [EMAIL PROTECTED] wrote: Java classpaths sound not actually contain .class files (although .jar files are included in classpaths). Assuming your java class in not in a package (which is a Bad idea, but looks to be the case from your java code), then you need to include in the classpath the directory containing your .class file. A sort of best practice would be to create a directory somewhere called classes and then to put your .class files in there, and add that dir to the classpath. If your java classes are in a package (again, a good idea, like maybe com.wmiddeendorf), then your .class files go unto appropriate subdirs under classes (like classes/com/wmiddeendorf). Hope that helps. Mark -Original Message- From: Wes Middendorff [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 18, 2007 4:32 PM To: CF-Talk Subject: CreateObject() with java I have a totally newb problem. I have a written a java class to unzip files (which works JRUN's jre), but I am trying to use it with coldfusion and am unable to get coldfusion to even recognize that it is there. I have set up the classpath in administrator and ensured several times that the path is correct. The contents of the classpath field in CFAdmin is: C:\CFusionMX7\runtime\jre\lib\YP_Unzip.class I am sure I have to have something configured incorrectly. here is my code (though I am not sure that this is the problem): COLDFUSION: cfset temp = createObject(java, YP_Unzip) JAVA: import java.io.*; import java.util.zip.*; class YP_UnZip { public void Unzip (String Args[]){ int BUFFER = 2048; int i; BufferedOutputStream dest = null; FileInputStream inputfile; ZipInputStream zipfile; if (Args.length != 0){ //loop over files to be unzipped for(i=0; i Args.length; i++){ System.out.print(Unzipping : ); System.out.print(Args[i]); System.out.println(); try{ inputfile = new FileInputStream(Args[i]); zipfile = new ZipInputStream(new BufferedInputStream(inputfile)); ZipEntry entry; while ((entry = zipfile.getNextEntry()) != null){ System.out.println(Extracting : +entry); int count; byte data[] = new byte[BUFFER]; //write the back to disk FileOutputStream outputfile = new FileOutputStream(entry.getName()); dest = new BufferedOutputStream(outputfile, BUFFER); while ((count = zipfile.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, count); } dest.flush(); dest.close(); } } catch(Exception e){ e.printStackTrace(); }//end try-catch block } //end for loop }//end if (Args.length != 0) else{ //code for error handling goes here - error missing file } }//main } Any help would be greatly appreciated. Thanks, Wes ~| Macromedia ColdFusion MX7 Upgrade to MX7 experience time-saving features, more productivity. http://www.adobe.com/products/coldfusion?sdid=RVJW Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:275772 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: CreateObject() with java
Might want to make it public class instead of class... It could also use a constructor (or make the method static). Russ -Original Message- From: Wesley Middendorff [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 18, 2007 5:08 PM To: CF-Talk Subject: Re: CreateObject() with java That helps a little, I am now getting some other error that is not so helpfull... Object Instantiation Exception. An exception occurred when instantiating a java object. The cause of this exception was that: YP_Unzip (wrong name: YP_UnZip). This shouldn't be so difficult. On 4/18/07, Gaulin, Mark [EMAIL PROTECTED] wrote: Java classpaths sound not actually contain .class files (although .jar files are included in classpaths). Assuming your java class in not in a package (which is a Bad idea, but looks to be the case from your java code), then you need to include in the classpath the directory containing your .class file. A sort of best practice would be to create a directory somewhere called classes and then to put your .class files in there, and add that dir to the classpath. If your java classes are in a package (again, a good idea, like maybe com.wmiddeendorf), then your .class files go unto appropriate subdirs under classes (like classes/com/wmiddeendorf). Hope that helps. Mark -Original Message- From: Wes Middendorff [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 18, 2007 4:32 PM To: CF-Talk Subject: CreateObject() with java I have a totally newb problem. I have a written a java class to unzip files (which works JRUN's jre), but I am trying to use it with coldfusion and am unable to get coldfusion to even recognize that it is there. I have set up the classpath in administrator and ensured several times that the path is correct. The contents of the classpath field in CFAdmin is: C:\CFusionMX7\runtime\jre\lib\YP_Unzip.class I am sure I have to have something configured incorrectly. here is my code (though I am not sure that this is the problem): COLDFUSION: cfset temp = createObject(java, YP_Unzip) JAVA: import java.io.*; import java.util.zip.*; class YP_UnZip { public void Unzip (String Args[]){ int BUFFER = 2048; int i; BufferedOutputStream dest = null; FileInputStream inputfile; ZipInputStream zipfile; if (Args.length != 0){ //loop over files to be unzipped for(i=0; i Args.length; i++){ System.out.print(Unzipping : ); System.out.print(Args[i]); System.out.println(); try{ inputfile = new FileInputStream(Args[i]); zipfile = new ZipInputStream(new BufferedInputStream(inputfile)); ZipEntry entry; while ((entry = zipfile.getNextEntry()) != null){ System.out.println(Extracting : +entry); int count; byte data[] = new byte[BUFFER]; //write the back to disk FileOutputStream outputfile = new FileOutputStream(entry.getName()); dest = new BufferedOutputStream(outputfile, BUFFER); while ((count = zipfile.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, count); } dest.flush(); dest.close(); } } catch(Exception e){ e.printStackTrace(); }//end try-catch block } //end for loop }//end if (Args.length != 0) else{ //code for error handling goes here - error missing file } }//main } Any help would be greatly appreciated. Thanks, Wes ~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 MX7 integration create powerful cross-platform RIAs http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJQ Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:275784 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CreateObject() with java
Thanks for your help everyone. I think I will be okay now. On 4/18/07, Russ [EMAIL PROTECTED] wrote: Might want to make it public class instead of class... It could also use a constructor (or make the method static). Russ -Original Message- From: Wesley Middendorff [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 18, 2007 5:08 PM To: CF-Talk Subject: Re: CreateObject() with java That helps a little, I am now getting some other error that is not so helpfull... Object Instantiation Exception. An exception occurred when instantiating a java object. The cause of this exception was that: YP_Unzip (wrong name: YP_UnZip). This shouldn't be so difficult. On 4/18/07, Gaulin, Mark [EMAIL PROTECTED] wrote: Java classpaths sound not actually contain .class files (although .jar files are included in classpaths). Assuming your java class in not in a package (which is a Bad idea, but looks to be the case from your java code), then you need to include in the classpath the directory containing your .class file. A sort of best practice would be to create a directory somewhere called classes and then to put your .class files in there, and add that dir to the classpath. If your java classes are in a package (again, a good idea, like maybe com.wmiddeendorf), then your .class files go unto appropriate subdirs under classes (like classes/com/wmiddeendorf). Hope that helps. Mark -Original Message- From: Wes Middendorff [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 18, 2007 4:32 PM To: CF-Talk Subject: CreateObject() with java I have a totally newb problem. I have a written a java class to unzip files (which works JRUN's jre), but I am trying to use it with coldfusion and am unable to get coldfusion to even recognize that it is there. I have set up the classpath in administrator and ensured several times that the path is correct. The contents of the classpath field in CFAdmin is: C:\CFusionMX7\runtime\jre\lib\YP_Unzip.class I am sure I have to have something configured incorrectly. here is my code (though I am not sure that this is the problem): COLDFUSION: cfset temp = createObject(java, YP_Unzip) JAVA: import java.io.*; import java.util.zip.*; class YP_UnZip { public void Unzip (String Args[]){ int BUFFER = 2048; int i; BufferedOutputStream dest = null; FileInputStream inputfile; ZipInputStream zipfile; if (Args.length != 0){ //loop over files to be unzipped for(i=0; i Args.length; i++){ System.out.print(Unzipping : ); System.out.print(Args[i]); System.out.println(); try{ inputfile = new FileInputStream(Args[i]); zipfile = new ZipInputStream(new BufferedInputStream(inputfile)); ZipEntry entry; while ((entry = zipfile.getNextEntry()) != null){ System.out.println(Extracting : +entry); int count; byte data[] = new byte[BUFFER]; //write the back to disk FileOutputStream outputfile = new FileOutputStream(entry.getName()); dest = new BufferedOutputStream(outputfile, BUFFER); while ((count = zipfile.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, count); } dest.flush(); dest.close(); } } catch(Exception e){ e.printStackTrace(); }//end try-catch block } //end for loop }//end if (Args.length != 0) else{ //code for error handling goes here - error missing file } }//main } Any help would be greatly appreciated. Thanks, Wes ~| ColdFusion MX7 by Adobe® Dyncamically transform webcontent into Adobe PDF with new ColdFusion MX7. Free Trial. http://www.adobe.com/products/coldfusion?sdid=RVJV Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:275791 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CreateObject() with java
On 4/18/07, Wes Middendorff [EMAIL PROTECTED] wrote: I have a totally newb problem. I have a written a java class to unzip files (which works Wes, Without commenting on the rest of your code... why exactly are you writing a java class to unzip files, when you can do it with native java in CF *WITHOUT* writing a custom class? http://www.cflib.org/udf.cfm?ID=997 Rick -- CFMBB - Coldfusion Message Boards, Version 1.21 Now Available! http://www.cfmbb.org ~| Deploy Web Applications Quickly across the enterprise with ColdFusion MX7 Flex 2 Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:275804 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4