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

Reply via email to