Zip created through java.util.zip but problem in windows XP compress folder

Hi friends,
I am a software developer ,working on java/j2ee.currently i am working in a document management software related to logistics.Here i am facing a problem at the time of open the zip file through windows XP's in built software called "Folder compress".It's creared through java.util.zip.zipoutputstream.but at time of open through xp compress folder software ,it's showing error that "you can't open this file , this file are protected for your computer security" , but when i trying to open it through winzip or winrar, it's not giving any problem.My also specefing the code snippet below :-
ZipOutputStream zip =  null;
     FileOutputStream fileWriter = null;
          try
               fileWriter = new FileOutputStream(destZipFile);
               zip = new ZipOutputStream(fileWriter);
               //required for XP compress
               zip.setMethod(ZipOutputStream.DEFLATED);
            zip.setLevel(Deflater.DEFAULT_COMPRESSION); //use default level
          }catch (Exception ex){
               ex.printStackTrace();
               System.exit(0);
          addFolderToZip("", srcFolder, zip);
          try
               zip.flush();
               zip.close();
               zip=null;
               fileWriter.close();
               fileWriter = null;
          }catch (Exception ex)
               //ex.printStackTrace();
               logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Zip folder processing");
          }I desperately looking for a help regarding this issue , if any body have any solution the please send at this forum.
Thanks,
Chiranjit

this file working file for winzip or winrar there is no problem.i am also sending the whole code of that java file that can help you better.
Program Name:     EdocRetrieveServiceSLBean.java
Description:     EdocRetrieveService CMP Bean Class
Classes:          EdocRetrieveServiceSLBean
Package:          net.mlog.edoc.ejb.entity
Modification History
<CR No>          <Date>               <Modified By>               <Comments>
Version 1.0     2005.12.01          Sutapa   Ray               Create
/** The sequence of methods to be called.
   ===============================================================================================================================
   1. mlogOriginDocumentAudit(String argActionDetails,int argDocumentId,int argActionId,String argActionByUserId)
   2. mlogDestinationBatchDownload(Vector TREEDATA,String SessionIDVal,String argUserId)
          a) Start DIR --
          private  String DoFolder(String folderNname)
          b) Create the folder
          private String CreateFolder(String FolderName,String newFolderPath)
          c) Zip the folder
          private void zipFolder(String srcFolder, String destZipFile)
          d) Add folders to zip file
          private void addToZip(String path, String srcFile, ZipOutputStream zip)
          e) Add the srcFolder to the zip stream.
          private void addFolderToZip(String path, String srcFolder, ZipOutputStream zip)
          f) Delete Directory from server
          public boolean deleteDir(File dir) {
   3. mpsDocumentView(String argUserId,Integer[] argSfxFileId)
   4. mlogOriginDocumentView(int argDocumentId,String argUserId)
   5. findDocTypeForDocId(Integer argDocId) throws RemoteException;
package net.mlog.edoc.ejb.session;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
import javax.ejb.ObjectNotFoundException;
import javax.ejb.FinderException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.naming.Context;
import javax.rmi.PortableRemoteObject;
import java.rmi.RemoteException;
//import lib for all entity beans
import net.mlog.edoc.ejb.entity.IDocumentCMP;
import net.mlog.edoc.ejb.entity.IDocumentCMPHome;
import net.mlog.edoc.ejb.entity.IDocumentTypeCMP;
import net.mlog.edoc.ejb.entity.IDocumentTypeCMPHome;
import net.mlog.edoc.ejb.entity.IDocumentAuditCMP;
import net.mlog.edoc.ejb.entity.IDocumentAuditCMPHome;
//import lib for reader class of properties file
import net.mlog.edoc.ejb.session.PropertiesFileReader;
//import lib for user Define File class
import net.mlog.edoc.ejb.Session.EFile;
//import lib for SFXWebClient
import net.mlog.edoc.webservice.sfxWeb.ISFXWebClientSLHome;
import net.mlog.edoc.webservice.sfxWeb.ISFXWebClientSL;
import java.sql.Date;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import java.util.zip.Deflater;
import java.util.Vector;
import java.util.Iterator;
import java.util.Collection;
import java.util.StringTokenizer;
import java.util.Enumeration;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.File;
import java.io.InputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileOutputStream;
//import lib for NGP Mail
import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueConnection;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.JMSException;
import weblogic.jms.extensions.WLQueueSession;
import weblogic.jms.extensions.XMLMessage;
//import javax.mail.*;
//import javax.mail.internet.*;
//import lib for USI
import com.msl.security.USIException;
import com.msl.security.USIServerAPI;
import com.msl.security.UserPolicyData;
import net.msl.util.logging.MLogger;
public class EdocRetrieveServiceSLBean implements SessionBean {
  private static final boolean VERBOSE = true;
  private SessionContext ctx;
  public void ejbActivate() {
  public void ejbRemove() {
  public void ejbPassivate() {
  public void setSessionContext(SessionContext ctx) {
    this.ctx = ctx;
  public void ejbCreate () throws CreateException {
  private static final MLogger logger;
  static
     logger = MLogger.getLogger(net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.class.getName(), "net/mlog/edoc/ejb/session/eDocRetrieveServiceMessagesXML");
//*********************KEEPING AUDITS OF DOCUMENTS BY MLOG ORIGIN PEOPLE*******************************
* <b>
* Used for Auditing the user action.
* </b>
* This function is called from various functions of eDocController
* <p>
* @param  argActionDetails Gives the details of Action in document audit.
* @param  argDocumentId gives the Document Id in Document Audit.
* @param  argActionId Action Id in Document Audit.
* @param  argActionByUserId User Id of the Docment Audit action.
* @return Returns a boolean value. 1 for success, 0 for Failure.
public boolean mlogOriginDocumentAudit(String argActionDetails,int argDocumentId,int argActionId,String argActionByUserId) throws RemoteException
     //NGP/JDK Logging
     boolean flag=false;
try{
     //getting context of the server
     InitialContext documentAuditCMPInitialContext=getInitialContext();
     Object objDocumentAuditCMPRef=null;
     try{
          objDocumentAuditCMPRef=documentAuditCMPInitialContext.lookup("DocumentAuditCMPBeanJNDI");
     catch(Exception e)
          //NGP/JDK Logging if JNDI Not found
          //logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","DocumentAuditCMPBeanJNDI"});
          logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","DocumentAuditCMPBeanJNDI not found");
     //find the maximum audit id in the Document_Audit table
     //Home interface reference of DocumentAuditCMP EJB
     //IDocumentAuditCMPHome iDocumentAuditCMPHomeRef=(IDocumentAuditCMPHome)PortableRemoteObject.narrow(objDocumentAuditCMPRef,IDocumentAuditCMPHome.class);
     IDocumentAuditCMPHome iDocumentAuditCMPHomeRef=(IDocumentAuditCMPHome)objDocumentAuditCMPRef;
     //Remote interface reference of DocumentAuditCMP EJB
     IDocumentAuditCMP iDocumentAuditCMPCreateRef=iDocumentAuditCMPHomeRef.create(new Timestamp(System.currentTimeMillis()),argActionDetails,argActionByUserId,new Integer(argActionId),new Integer(argDocumentId));
     //set flag to true if Document is audited
     flag=true;
}//end of try
catch(Exception expt)
     //logger.finer(expt);
     logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.CreateException","Exception in creating Document Audit record");
  return flag;
//*********************BATCH DOWNLOAD OF DOCUMENTS BY MLOG ORIGIN PEOPLE*******************************
* <b>
* Used for Validating the documents.
* </b>
* This function is called from Struts
* <p>
* @param  TREEDATA Treeset obtained after search.
* @param  SessionIDVal gives the Session Value Id.
* @return Returns a boolean value. 1 for success, 0 for Failure.
public byte[] mlogDestinationBatchDownload(Vector TREEDATA,String SessionIDVal,String argUserId) throws RemoteException
     //NGP/JDK Logging
     /*FileHandler handler = null;
    Logger logger=null;
     try
       PropertiesFileReader propertiesFileReaderRef=new  PropertiesFileReader();
        String logFile=propertiesFileReaderRef.getProperties("/edoc.properties","EDOC_LOG");
       handler = new FileHandler("eDoc.log",0,1, true);
       logger = Logger.getLogger("ErrorMsg");
       logger.addHandler(handler);
       logger.setLevel(Level.ALL);
    }catch(Exception excp)
         NGP/JDK Logging warning
         logger.log(Level.WARNING, "{0} : Unable to find Resource Bundle File : {1}",new Object[] {"MSG001","ErrorMsg"});
     //Remote interface reference of SFXWebClientSL
     ISFXWebClientSL iSFXWebClientSLRef=null;
     //Home interface reference of SFXWebClientSL
     ISFXWebClientSLHome iSFXWebClientSLHomeRef=null;
     Vector filePath=new Vector();
     byte[] fileContent=null;
     String eDocRoot="";
     String eDocPathMain="";
     String eDocPath="";
     File tempRootFileforDelete = null;
     if (TREEDATA.capacity() != 0 )
          String BLNODirPath="";
          String PONODirPath="";
          String SONODirPath="";
          // added for doc type level--2005.11.27--samar
          String docTypeDirPath="";
          String filepath="";
          try
             PropertiesFileReader propertiesFileReaderRef=new  PropertiesFileReader();
             filepath=propertiesFileReaderRef.getProperties("/edoc.properties","TEMP_FILE_DIR");
             logger.finer("File Path:" +filepath);
          }catch(Exception excp)
               excp.printStackTrace();
               logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.IOException","TEMP_FILE_DIR property (edoc.properties) not found");
          eDocRoot=CreateFolder("eDocTemp",filepath+File.separator);
          // added for top level--2005.12.02--samar
          //eDocRoot=CreateFolder("eDocTemp",System.getProperty("user.home")+File.separator);
          //eDocPath=CreateFolder(SessionIDVal,eDocRoot+File.separator);
          Enumeration TREEDATAEn = TREEDATA.elements();               //Setting The Tree Folder
          String   BLNO="";
          String   PONO="";
          String   SONO="";
          String   DNO ="";
          while(TREEDATAEn.hasMoreElements())
               StringTokenizer st = new StringTokenizer((TREEDATAEn.nextElement()).toString(),"_");
               while (st.hasMoreTokens()) // Extract All the Fields Of Every Vector Element
                    BLNO = st.nextToken();          // CSBWNO
                    PONO = st.nextToken();         // PONO
                    SONO = st.nextToken();        // SONO
                    DNO = st.nextToken();          // DNO
                    eDocPathMain=CreateFolder(SessionIDVal,eDocRoot+File.separator);
                    eDocPath=CreateFolder("eDoc",eDocPathMain+File.separator);
                    BLNODirPath = CreateFolder(BLNO,eDocPath+File.separator);
                    PONODirPath = CreateFolder(PONO,BLNODirPath+File.separator);
                    SONODirPath = CreateFolder(SONO,PONODirPath+File.separator);
                    // added for doc type level--2005.11.27--samar
                    docTypeDirPath=CreateFolder(findDocTypeForDocId(new Integer(DNO)),SONODirPath+File.separator);
                    File tempRootFile=new File(eDocRoot);
                    tempRootFile.canWrite();
                    filePath.add(tempRootFile.getParent());
                    tempRootFileforDelete = tempRootFile;
                    //File tempeDocPathMainFile=new File(eDocPathMain);
                    //filePath.add(tempeDocPathMainFile.getParent());
                    //2005-12-01::code change for top level directory deletion
                    //File tempFile=new File(eDocPath);//BLNODirPath);
                    //filePath.add(tempFile.getParent());
                    filePath.add(eDocPathMain);
                    filePath.add(eDocPath);
                    filePath.add(BLNODirPath);
                    filePath.add(PONODirPath);
                    filePath.add(SONODirPath);
                    // added for doc type level--2005.11.27--samar
                    filePath.add(docTypeDirPath);
                    /* Access The Data from DataBase Temp Storage with Document Id And Store In This SO Folder */
                    /*Long Raw*/
                    try
                         InitialContext initialContext=new InitialContext();
                         int sfxid=0;
                         /*DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
                         OraclePooledConnection pc = new OraclePooledConnection("jdbc:oracle:thin:hr/hr@essoraclesvr:1521:essorcl","edoc","edoc");
                         Connection con=new DBCon().Connect();//pc.getConnection();
                         PreparedStatement pstm=con.prepareStatement("select SFX_FILE_ID from DOCUMENT where DOCUMENT_ID=?");
                         //getting context of the server
                         InitialContext documentCMPInitialContext=getInitialContext();
                         Object objDocumentCMPRef=null;
                         try{
                              objDocumentCMPRef=documentCMPInitialContext.lookup("DocumentCMPBeanJNDI");
                         catch(Exception e)
                               //logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","DocumentCMPBeanJNDI"});
                               logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","DocumentCMPBeanJNDI not found");
                         //Home interface reference of DocumentCMP EJB
                         //IDocumentCMPHome iDocumentCMPHomeRef=(IDocumentCMPHome)PortableRemoteObject.narrow(objDocumentCMPRef,IDocumentCMPHome.class);
                         IDocumentCMPHome iDocumentCMPHomeRef=(IDocumentCMPHome)objDocumentCMPRef;
                         IDocumentCMP documentCMPRef=null;
                         //Remote interface reference of DocumentCMP EJB
                         try{
                              documentCMPRef=iDocumentCMPHomeRef.findByPrimaryKey(new Integer(DNO));
                         catch(Exception e)
                              logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ObjectNotFound","Document Id not found");
                         /*pstm.setInt(1,Integer.parseInt(DNO));
                         ResultSet rs1=pstm.executeQuery();
                         if(rs1.next()){
                         sfxid=rs1.getInt(1);
                         sfxid=documentCMPRef.getSfxFileId().intValue();
                         logger.finer("sfxid==="+sfxid);
                         String strFile=documentCMPRef.getDocumentName().toString();
                         //SFX lookup
                         //InitialContext initialContext=new InitialContext();
                         Object sfxWebClient=null;
                         try{
                                sfxWebClient=initialContext.lookup("SFXWebClientJNDI");
                         catch(Exception e)
                              //NGP/JDK logging if JNDI not found
                              //logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","SFXWebClientJNDI"});
                              logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","SFXWebClientJNDI not found");
                         iSFXWebClientSLHomeRef=(ISFXWebClientSLHome)PortableRemoteObject.narrow(sfxWebClient,ISFXWebClientSLHome.class);
                         iSFXWebClientSLRef=iSFXWebClientSLHomeRef.create();//SFXWebClient reference creation
                         if(iSFXWebClientSLRef!=null)
                              //logger.finer("ffffffff---");
                              int arrSFXFileId[]=new int[1];
                              arrSFXFileId[0]=sfxid;
                              Object objEFile[]=iSFXWebClientSLRef.retrieveDocument(argUserId,arrSFXFileId);
                              if(objEFile.length>0)
                                   byte b[]=(byte[])objEFile[1];
                                   String f=strFile.substring(strFile.lastIndexOf(File.separator)+1,strFile.length());
                                   // changed(instead of SONODirPath now docTypeDirPath) for doc type level--2005.11.27--samar
                                   FileOutputStream fout=new FileOutputStream(docTypeDirPath+File.separator + f);
                                   //logger.finer("SONODirPath+File.separator + f---"+SONODirPath+File.separator + f);
                                   filePath.add(docTypeDirPath+File.separator + f);
                                   int j;
                                   for(j=0;j<b.length;j++)
                                        fout.write(b[j]);
                                   fout.close();
                                   //for auditing the document
                                   //logger.finer("Document download audited");
                                   boolean flagAudit=mlogOriginDocumentAudit("Document has been downloaded",Integer.parseInt(DNO),5,argUserId);
                                   //logger.finer("Audit complete"+flagAudit);
                                   if(logger.isFinerLoggable()) {
                                        logger.finer("Audit complete"+flagAudit);
                         //Delete after finish
                         tempRootFile.delete();
                     }catch(Exception e)
                         //e.printStackTrace();
                         logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Folder creation processing");
                    /* End Long Raw     */
                  }// end of while hasMoreTokens
           }// end of while hasMoreElements
     }else{ }
     /* Zip */
      try
          zipFolder(eDocPath+File.separator,eDocPath+".zip");
      }catch(Exception excp)
          ////logger.finer(excp.toString());
          logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Zip processing");
     // send the byte array for the file
     String fileName=eDocPath+".zip";
     try{
               File file=new File(fileName);
               InputStream is = new FileInputStream(file);
               // Get the size of the file
               long length = file.length();
               // You cannot create an array using a long type.It needs to be an int type.
               // Before converting to an int type,check to ensure that file is not larger than Integer.MAX_VALUE.
               //Kept for future requirement if any
               if (length > Integer.MAX_VALUE) {
                    // File is too large
               // Create the byte array to hold the data
                fileContent = new byte[(int)length];
               // Read in the bytes
               int offset = 0;
               int numRead = 0;
               while (offset < fileContent.length
                       && (numRead=is.read(fileContent, offset, fileContent.length-offset)) >= 0) {
                    offset += numRead;
               // Ensure all the bytes have been read in
               if (offset < fileContent.length) {
                    throw new IOException("Could not completely read file "+file.getName());
               // Close the input stream and return bytes
               is.close();
     }catch(Exception e){
      deleteDir(tempRootFileforDelete);
     //trying for deleting folder and zip file
     File file=new File(fileName);
     if(file.exists())
             file.delete();
             //logger.finer("File Deleted successfully");
     if(file.exists()){
             //logger.finer("File Not Deleted ");
     /* File FileToDelete = new File(eDocPath+".zip");
     boolean  DelStatus1 = deleteDir(FileToDelete);
      //logger.finer("Deletion 1:"+DelStatus1 );
      File FolderToDelete = new File(eDocPath);
     boolean  DelStatus2 = deleteDir(FolderToDelete);
      //logger.finer("Deletion 2:"+DelStatus2);
      for(int index=filePath.size()-1;index>=0;index--)
           File delFile=new File(filePath.elementAt(index).toString());
           //logger.finer(delFile.getAbsolutePath());
           if(delFile.exists())
                //logger.finer("Before delete---123");
                //logger.finer("File Deleted========>"+delFile.delete());
                //logger.finer("After delete---123");
                //logger.finer(delFile.getAbsolutePath()+"-----------"+delFile.exists());
      return fileContent;
/* ***************************Start DIR *********************/
private  String DoFolder(String folderNname)
     File f;
     f = new File(folderNname);
     f.mkdir();                                                   // Create The Folder
   //f.deleteOnExit();                                  //R n D to Delete The zip folders only  */
     return(folderNname+File.separator);
//to create the folder
private String CreateFolder(String FolderName,String newFolderPath)
          String NewDir ="";
          NewDir=newFolderPath + FolderName;
          newFolderPath=DoFolder(NewDir);
          return(NewDir);
//To zip the folder
private void zipFolder(String srcFolder, String destZipFile)
     ZipOutputStream zip =  null;
     FileOutputStream fileWriter = null;
          try
               fileWriter = new FileOutputStream(destZipFile);
               zip = new ZipOutputStream(fileWriter);
               //required for XP compress
               zip.setMethod(ZipOutputStream.DEFLATED);
            zip.setLevel(Deflater.DEFAULT_COMPRESSION); //use default level
          }catch (Exception ex){
               ex.printStackTrace();
               System.exit(0);
          addFolderToZip("", srcFolder, zip);
          try
               zip.flush();
               zip.close();
               zip=null;
               fileWriter.close();
               fileWriter = null;
          }catch (Exception ex)
               //ex.printStackTrace();
               logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Zip folder processing");
     //     File f2= new File(destZipFile);
*  Write the content of srcFile in a new ZipEntry, named path+srcFile,of the zip stream
*  The result is that the srcFile will be in the path folder in the generated archive.
*  @param path          String, the relative path with the root archive.
*  @param srcFile     String, the absolute path of the file to add
*  @param zip          ZipOutputStram, the stream to use to write the given file.
//the folders are added to zip file
private void addToZip(String path, String srcFile, ZipOutputStream zip)
     File folder = new File(srcFile);
     //folder.deleteOnExit();
     if (folder.isDirectory()) {
          addFolderToZip(path, srcFile, zip);
     else {
          //Transfer bytes from in to out
          byte[] buf = new byte[1024];
          int len;
          FileInputStream in = null;
          try {
               in = new FileInputStream(srcFile);
               // void putNextEntry(ZipEntry e) Begins writing a new ZIP file entry
               // and positions the stream to the start of the entry data.
               zip.putNextEntry(new ZipEntry(path +File.separator+ folder.getName()));
               while ((len = in.read(buf)) > 0)
                    zip.write(buf, 0, len);
          }catch (Exception ex){
               ex.printStackTrace();
               logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Adding to Zip Folder");
          }finally{
               try
                    //2005-12-01::file pointer close
                    in.close();
               }catch(Exception e){
                    e.printStackTrace();
                    logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Adding to Zip Folder");
     folder.delete(); //we addedd for DELETE
* add the srcFolder to the zip stream.
* @param path          String, the relatif path with the root archive.
* @param srcFile     String, the absolute path of the file to add
* @param zip          ZipOutputStram, the stream to use to write the given file.
private void addFolderToZip(String path, String srcFolder, ZipOutputStream zip)
     File folder = new File(srcFolder);
     folder.canWrite();
     //folder.deleteOnExit();
     String fileListe[] = folder.list();
     try
          int i = 0;
          while (true)
          addToZip(path+File.separator+ folder.getName(), srcFolder+File.separator+fileListe, zip);
          i++;
     }catch (Exception ex)
     logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Naming after adding to Zip Folder");
/* $$$$$$$$$$$$$$$$$           End Zipping               $$$$$$$$$$$$$$$ */
/****************Start Of Deleting Directory from server***********/
public boolean deleteDir(File dir) {
     // to see if this directory is actually a symbolic link to a directory,
     // we want to get its canonical path
     //- that is, we follow the link to the file it's actually linked to
     File candir;
     try {
          candir = dir.getCanonicalFile();
     } catch (IOException e) {
          return false;
     // a symbolic link has a different canonical path than its actual path,
     // unless it's a link to itself
     if (!candir.equals(dir.getAbsoluteFile())) {
          //this file is a symbolic link, and there's no reason for us to follow it,
          //because then we might be deleting something outside of the directory we were told to delete
          return false;
     // now we go through all of the files and subdirectories in the directory and delete them one by one
     File[] files = candir.listFiles();
     if (files != null) {
     for (int i = 0; i < files.length; i++) {
          File file = files[i];
          //file read only set false
          //in case this directory is actually a symbolic link, or it's empty,
          //we want to try to delete the link before we try anything
          boolean deleted = file.delete();
          if (!deleted) {
               // deleting the file failed, so maybe it's a non-empty directory
               if (file.isDirectory()) deleteDir(file);
               // otherwise, there's nothing else we can do
     // now that we tried to clear the directory out, we can try to delete it again
     return dir.delete();
/************End Of Deleting Directory *********************/
private InitialContext getInitialContext() throws NamingException {
try {
return new InitialContext();
} catch (NamingException ne) {
//logger.finer("Please make sure that the server is running.");
throw ne;
//*****************************WEB SERVICE FILE RETRIEVE IMPLEMENTATION FOR MPS PEOPLE*************************************************
* <b>
* Used for Retrieval of a document.
* </b>
* This function is called from retrieveDocument function of MPStoEdocWebServiceSLBean.
* <p>
* @param argUserId User Id of the user who wants to retrieve the document
* @param argSfxFileId[] Sfx File Id which gives the reference number of the document(s) in the SFX database.
* @return Returns a one dimentional Object array containing a series of file name and file content of the retrieved documents.
public Object[] mpsDocumentView(String argUserId,Integer[] argSfxFileId) throws RemoteException
     //NGP/JDK logging
     logger.finer("mpsDocumentView called--");
     try{
          argUserId=argUserId.toUpperCase();
     catch(Exception e)
          e.printStackTrace();
     logger.finer("mpsDocumentView argSfxFileId[0]--"+argSfxFileId[0]);
     Object[] searchResult=null;
     /*FileHandler handler = null;
Logger logger=null;
     int finalIndex=0;
     try
//PropertiesFileReader propertiesFileReaderRef=new PropertiesFileReader();
     //String logFile=propertiesFileReaderRef.getProperties("/edoc.properties","EDOC_LOG");
//handler = new FileHandler("eDoc.log",0,1, true);
//logger = Logger.getLogger("ErrorMsg");
//logger.addHandler(handler);
//logger.setLevel(Level.ALL);
}catch(Exception excp)
     //NGP/JDK Logging warning
     //logger.log(Level.WARNING, "{0} : Unable to find Resource Bundle File : {1}",new Object[] {"MSG001","ErrorMsg"});
     logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","PurchaseOrderCMPBeanJNDI not found");
     Object objDocumentFile[]=null;
     ISFXWebClientSLHome iSFXWebClientSLHomeRef=null;
     ISFXWebClientSL iSFXWebClientSLRef=null;
     try{
          //Locating SFX WEB CLIENT SESSION BEAN
          InitialContext initialContext=new InitialContext();
          Object sfxWebClient=null;
          try{
               sfxWebClient=initialContext.lookup("SFXWebClientJNDI");
          catch(Exception e)
               //NGP/JDK Logging if JNDI not found
               //logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","SFXWebClientJNDI"});
               logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","SFXWebClientJNDI not found");
          iSFXWebClientSLHomeRef=(ISFXWebClientSLHome)PortableRemoteObject.narrow(sfxWebClient,ISFXWebClientSLHome.class);
          //creation of SFX we client
          iSFXWebClientSLRef=iSFXWebClientSLHomeRef.create();
          int arrSFXFileId[]=new int[argSfxFileId.length];
          logger.finer("SFXWebClient created----");
          //holds the sequence of SFX file id in the array
          //EFile file=new EFile();
          //getting context of the server
          InitialContext documentCMPInitialContext=getInitialContext();
     Object objDocumentCMPRef=null;
     int docId=0;
     try{
          objDocumentCMPRef=documentCMPInitialContext.lookup("DocumentCMPBeanJNDI");
     catch(Exception e)
               //NGP/JDK Logging if JNDI not found
               //logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","DocumentCMPBeanJNDI"});
               logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","DocumentCMPBeanJNDI not found");
     //Home interface reference of DocumentCMP EJB
     //IDocumentCMPHome iDocumentCMPHomeRef=(IDocumentCMPHome)PortableRemoteObject.narrow(objDocumentCMPRef,IDocumentCMPHome.class);
          IDocumentCMPHome iDocumentCMPHomeRef=(IDocumentCMPHome)objDocumentCMPRef;
     //find the document id in the Document table from the SFx File Id
          for(int index=0;index<argSfxFileId.length;index++)
               arrSFXFileId[index]=argSfxFileId[index].intValue();
               logger.finer("mpsDocumentView arrSFXFileId[index]--"+arrSFXFileId[index]);
     logger.finer("For Document auditing----");
     //Remote interface reference of DocumentCMP EJB
     IDocumentCMP iDocumentCMPRef=iDocumentCMPHomeRef.findDocIdBySfxId(new Integer(arrSFXFileId[index]));
               docId=iDocumentCMPRef.getDocumentId().intValue();
               //for document audit
               try{
                    boolean flagAudit=mlogOriginDocumentAudit("Document is Viewed",docId,5,argUserId);
               catch(Exception e)
                    //logger.finer("Document cannot be audited----");
                    logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in audit processing");
          //call the retrieveDocument method for the above array of elements
          //Object[] tempObjDocumentFile=iSFXWebClientSLRef.retrieveDocument(argUserId,arrSFXFileId);
          //EFile file=new EFile();
          //for(int index=0;index<tempObjDocumentFile.length;index++){
          //     file= (EFile) tempObjDocumentFile[index];
          //     objDocumentFile[finalIndex++]=file.getDocFileName();
          //     objDocumentFile[finalIndex++]=file.getDocFileContent();
          objDocumentFile=iSFXWebClientSLRef.retrieveDocument(argUserId,arrSFXFileId);
          //EFile[] efileArray = (EFile[]) = objDocumentFile;
          searchResult = new Object[efileArray.length*2];
          for (int i=0;i<efileArray.length;i=i+2)
               EFile currentFile = efileArray[i];
               searchResult[i] = currentFile.getDocFileName();
               searchResult[i+1] = currentFile.getDocFileContent();
          searchResult=iSFXWebClientSLRef.retrieveDocument(argUserId,arrSFXFileId);
     }//end of try
     catch(Exception expt)
          //logger.finer(expt);
          logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in retrieve from SFX");
     //if exception occurs returns null as per initilisation above
     //logger.finer("mpsDocumentView size--"+objDocumentFile.length);
     return searchResult;
//**************************** FILE RETRIEVE IMPLEMENTATION FOR MLOG PEOPLE*******************************
* <b>
* Used for Retrieval of a document.
* </b>
* This function is called from struts.
* <p>
* @param argDocumentId Documnet Id which gives the ID of the document in the eDoc database..
* @param argUserId User Id of the user who wants to retrieve the document
* @return Returns a one dimentional Object array containing a series of file name and file content of the retrieved documents.
public Object[] mlogOriginDocumentView(int argDocumentId,String argUserId) throws RemoteException
     //NGP/JDK Logging
     logger.finer("mlogOriginDocumentView called--");
     try{
          argUserId=argUserId.toUpperCase();
     catch(Exception e)
          //e.printStackTrace();
          logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in uppercase");
//logger.finer("mlogOriginDocumentView-- argDocumentId---"+argDocumentId);
     /*FileHandler handler = null;
Logger logger=null;
     try
//PropertiesFileReader propertiesFileReaderRef=new PropertiesFileReader();
     //String logFile=propertiesFileReaderRef.getProperties("/edoc.properties","EDOC_LOG");
//handler = new FileHandler("eDoc.log",0,1, tr

Similar Messages

  • Create a java.util.Map in JNI

    hello all,
    Can anyone tell me how to create & use Java Maps in my C++ code...
    I've used java.util.Vector, it works fine.
    I work on a Sun Fire V440 machine.
    regards,
    gautam.

    Denise,
    I think that will break your license agreement with Sun, so you probably don't want to do that, right? ;)
    I think you should try to figure out what the exact cause of your problem is. Off hand, it almost sounds like your applet uses v1.3 api, but your still using the old <Applet> html tag and not the new <Object> tag. Is this right?
    -Ron

  • Access denied ("java.util.PropertyPermission" "user.timezone" "write") [WINDOWS 7 64bit]

    Hello,
    we got on several computers the error message
    access denied (java.util.PropertyPermission" "user.timezone" "write")
    when we try to open an internal website. Until today everything worked fine.
    An update on Java for windows 7 64, Version 7 Update 45 didnt solve the problem.
    I tried to set the Java security permissions in the control panel to middle but it also didnt work after this change.
    We also got this problem on another computer when we try to open an external site which also use Java.
    Did anyone have an idea how to fix this problem?

    Hi Guys.
    I solved the problem adding a rule in the following file
    $JAVA_HOME\lib\security\java.policy
    grant {
        permission java.util.PropertyPermission "user.timezone", "write";
    After I killed the java process and restarted. The problem dissapeared

  • How to create a java.util.Date object from a date String?

    How do I convert a String representation of a date in for the format dow mon dd hh:mm:ss zzz yyyy (e.g. "Mon Aug 27 17:12:59 EDT 2001") into a Date object? This you might note is the output of the Date classes toString() method. I don't want to have to parse this string. Thanks!

    Try this out
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyyMMdd");
    String d = "19990831";
    Calendar cal = Calendar.getInstance();
    cal.setTime(sdf.parse(d));To create the SimpleDateFormat with a diffrent format check out all the possibilities here
    http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html
    Hope this helps
    Regards
    Omer

  • (Again) java.util.Date vs java.sql.Date

    Hi there,
    (Again) Im trying to understand the EXACT difference between
    java.util.Date vs java.sql.Date.
    Googling, I can see that this is a very "popular" subject, but I still
    cannot figure out it exactly.
    Many writers claim that java.sql.Date only stores the DATE part (yyyy-
    mm-dd) but not the TIME part (hh:MM:ss) of a Date/Time value, but that
    I can easily disprove:
                    java.util.Date ud = new java.util.Date();                 java.sql.Date sd = new java.sql.Date(ud.getTime());                 System.out.println(DateFormatUtils.                                 format(ud, "yyyy-MM-dd HH:mm:ss.SSS"));                 System.out.println(DateFormatUtils.                                 format(sd, "yyyy-MM-dd HH:mm:ss.SSS"));
    Output:
                    2009-09-18 15:17:36.635                 2009-09-18 15:17:36.635
    So, apparently, java.sql.Date and java.util.Date have THE SAME
    precision (at least down to the millisecs...).
    And the official API documentation, really looks more confusing than
    helpful to me::
    *"java.sql.Date:*
    *A thin wrapper around a millisecond value that allows JDBC to identify*
    *this as an SQL DATE value. A milliseconds value represents the*
    *number of milliseconds that have passed since January 1, 1970*
    *00:00:00.000 GMT.*
    *To conform with the definition of SQL DATE, the millisecond values*
    *wrapped by a java.sql.Date instance must be 'normalized' by setting*
    *the hours, minutes, seconds, and milliseconds to zero in the*
    *particular time zone with which the instance is associated. "*
    Exactly what means "an SQL DATE value" ? How EXACTLY does it differ
    from a java.util.Date value?
    Most importantly: WHY does JDBC need to distinguish between them?
    And, here again: *"a java.sql.Date instance must be 'normalized' by*
    *setting the hours, minutes, seconds, and milliseconds to zero in the*
    *particular time zone..."*
    What does that mean exactly? Apparently, the constructor doesnt
    enforce this restriction, per the example above. So what's the REAL
    point with this type, java.sql.Date?
    Very greatful, if you can help me clarify this, once and for all.
    TIA,

    And the official API documentation, really looks more confusing than helpful to me:The problem is that you need to understand SQL as well as Java for this to make sense. It's not the Java API's job to tell you how your SQL database works - there's a myriad of subtle differences even when the DB is compliant with the SQL spec.
    Most compliant databases support DATE, TIME, and TIMESTAMP values. DATE represents only a date. TIME represents only a time. TIMESTAMP represents both. There are further complicating factors, but that's roughly how it stands.
    In Java the normal type for representing time is (or was when the API was created) the java.util.Date but this is a close approximation only to the TIMESTAMP value. In order to bring the two together the java.sql.Date, java.sql.Time and java.sql.Timestamp classes were created. Making them derive from java.util.Date was probably not a good idea.
    java.util.Date suffers from a number of deficiencies. java.util.Calendar was supposed to address them but didn't really succeed. The JodaTime library is rather better, but it's all a lot more complicated than you might expect - partly because time management really is a much harder problem than it appears at first glance - there are timezones, leap years, leap seconds, the difference between astronomical and atomic time, and so on and so forth.

  • How to use java.util.UUID in a function?

    This works:
    create or replace and compile
    java source named "RandomUUID"
    as
    public class RandomUUID
    public static String create()
    return "123";
    But this does not work:
    create or replace and compile
    java source named "RandomUUID"
    as
    public class RandomUUID
    public static String create()
    return java.util.UUID.randomUUID().toString();
    Can anybody explain?
    The log window shows the following strings:
    oracle.dbtools.worksheet.commands.scriptrunner.task.ScriptRunnerTask
    oracle.dbtools.raptor.newscriptrunner.PLSQL.reportWarning(PLSQL.java:261)
    But I have no idea what this could mean.

    This is the forum for Oracle's SQL Developer tool, not for general SQL and PL/SQL questions. Questions like this will get a better response in the PL/SQL forum, or a java forum.
    Incidentally, you need to be clearer on what "does not work" means. Does not compile? Doesn't run? Doesn't produce the expexted result.

  • Cannot import java.util.concurrent.locks ... WHY?

    Why is Xcode unable to find the java.util.concurrent.locks package. The class browser knows it exists. For example the entry for the ReentrantLock class looks like this in the browser class window:
    ReentrantLock (java.util.concurrent.locks)
    Xcode knows about other java.util packages such as java.util.ResourceBundle which I have been accessed successfully in other parts of my projecgt.
    Here is a source file and the resulting compiler error:
    The source file:
    // Foo.java
    import java.util.ResourceBundle;
    import java.util.concurrent.locks;
    public class Foo { }
    The compiler error:
    compile:
    Compiling 2 source files to /Users/Terry/Desktop/JAVA/PROJECTS/Logic/bin
    /Users/Terry/Desktop/JAVA/PROJECTS/Logic/src/Foo.java:3: cannot find symbol
    symbol : class locks
    location: package java.util.concurrent
    import java.util.concurrent.locks;
    ^
    1 error
    BUILD FAILED
    Help or hints would be greatly appreciated!

    Well the reason to your problem is very simple... java.util.concurrent.locks is a package... Not a class.
    if you want to import a specific class, the class should be written at the end like you did for import java.util.ResourceBundle; but if you want to import a whole package you need to add the little star at the end :
    import java.util.concurrent.locks.*;
    Or else, you only import the class you need :
    import java.util.concurrent.locks.ReentrantLock;

  • Implement callback for an asynchronous BPEL process through Java

    Hi ,
    I am trying to implement a callback functionality for an asynchronous BPEL process through java.
    I found the code in the samples folder of SOA suite installation folder .
    <SOA_HOME>\bpel\samples\tutorials\102.InvokingProcesses\rmi\com\otn\samples\async.
    There is an AsyncInstanceWatchdog object which registers a callback object(in this case an object of AsyncCallbackImpl class) for a specific CONVERSATION_ID.
    String convId = GUIDGenerator.generateGUID();
    nm.setProperty(NormalizedMessage.CONVERSATION_ID, convId);
    deliveryService.post(proc_name, "initiate", nm);
    // register the callback
    watchdog.registerAsyncCallback(convId, testAsyncHandler,
    locator.getDomainAuth());
    // start it
    watchdog.start();
    There is no problem till the last line. But once the BPEL process returns the control( does a callback), it throws the following error.
    May 25, 2010 3:36:06 PM oracle.j2ee.rmi.RMIMessages EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER
    WARNING: Exception returned by remote server: {0}
    ORABPEL-02118
    Variant not found.
    The variant "output" has not been declared in the current scope. All variants must be declared in the scope before being accessed.
    Please check that the variant "output" is properly declared; otherwise there may be a misspelling in the name of the variant.
         at com.collaxa.cube.engine.core.Scope.getVariantRV(Scope.java:535)
         at com.collaxa.cube.engine.CubeEngine.getFieldValue(CubeEngine.java:2668)
    For your reference the variable output is declared in the definition of AsyncCallbackImpl (which implements the IAsyncInstanceCallback interface).
    There are 2 methods defined in the AsyncCallbackImpl class.
    public void onResult(Map pResultMessage) {
    System.out.println("called back! ");
    Iterator iTest = pResultMessage.keySet().iterator();
    while (iTest.hasNext()) {
    String key = (String)iTest.next();
    System.out.println(XMLHelper.elementToString((Element)pResultMessage.get(key)));
    public String getVariableName() {
    return "output";
    The variable name is same given in the sample code. And the BPEL process returns variable named output. So the name should not be a problem.
    Is it because of the scope of the variable.. If so, how do I change it.
    Any help would be appreciated.
    Edited by: saptarishi on May 25, 2010 4:24 PM
    Edited by: saptarishi on May 26, 2010 4:45 PM

    Solved it by some googling .... :)
    Here is the link:-
    [http://abhishek-soablog.blogspot.com/2008/09/orabpel-02118.html]
    or
    [http://beautifulwaste.blogspot.com/2008/04/calling-asynchronous-bpel-process.html]
    Both gives the same solution..
    In pre 10.1.3.3 release the default behaviour were to keep global variable information along with the instance information for completed BPEL processes.
    In 10.1.3.3 or later, this behaviour changed for performance reasons so that the default behaviour is now, not to keep any global variables for a BPEL process once the BPEL process has completed.
    You can configure this behaviour on a process level basis by using the parameter keepGlobalVariables in the bpel.xml file for the specific process:
    <BPELSuitcase>
    <BPELProcess src=".........." id="...........">
    <configurations>
    <property name="keepGlobalVariables">true</property>
    </configurations>
    </BPELProcess>
    </BPELSuitcase>
    Thanks
    saptarishi

  • Java.io.NotSerializableException: java.util.RandomAccessSubList

    Hi,
    I'm testing a software but I receive this error message:
    java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
            java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.util.RandomAccessSubList
            at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:173)
            at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)
            at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
            at $Proxy7.getDataPackage(Unknown Source)
            at gaia.dpct.cu3.avu.gsr.server.GsrSourceIdServerRmiImpl.getDataPackage(GsrSourceIdServerRmiImpl.java:73)
            at gaia.dpct.cu3.avu.gsr.reader.GsrSystemRowReaderStrategy.loadData(GsrSystemRowReaderStrategy.java:52)
            at gaia.dpct.pfs.infraimpl.PFSGenericPersistenceManager.loadData(PFSGenericPersistenceManager.java:455)
            at gaia.dpct.pfs.infraimpl.PFSPersistenceManagerAdpaterImpl.loadData(PFSPersistenceManagerAdpaterImpl.java:318)
            at gaia.cu1.tools.infraimpl.GenericDataTrain.run(GenericDataTrain.java:546)
            at gaia.dpct.pfs.infraimpl.PFSDataTrainAdapterImpl.run(PFSDataTrainAdapterImpl.java:166)
            at gaia.dpct.pfs.nodes.TrainManager$TrainExecution.run(TrainManager.java:735)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
            at java.util.concurrent.FutureTask.run(FutureTask.java:138)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
            at java.lang.Thread.run(Thread.java:619)
    Caused by: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.util.RandomAccessSubList
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1333)
            at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
            at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
            at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:306)
            at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:155)
            ... 16 more
    Caused by: java.io.NotSerializableException: java.util.RandomAccessSubList
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
            at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
            at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
            at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
            at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
            at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:274)
            at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:315)
            at sun.rmi.transport.Transport$1.run(Transport.java:159)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
            at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
            ... 3 moreI checked all the code but the objects I use are instantiated from Serializable classes.
    I read something about "java.util.RandomAccessSubList" but what is this? I use List and Map.
    Are there problem with the List and the Map I use?
    Could someone help me?
    Thanks, bye bye.

    You have a List member whose value is derived from List.subList(), which is implemented by the class named in the exception, which isn't serializable. Change it to
    subList = new LinkedList<T>(list.subList());where T is whatever it should be.
    You should do this anyway, as the subList is merely a view of the original list, so if it was serializable it would take the entire original list with it.

  • When included  import java.util.* then why include import java.util.Gregori

    Hi,
    In my program I hava inported the java package like
    import java.util.*;
    import java.sql.*;
    import java.text.*;
    then for using some classes like Gregorial calender,Date etc,I have to again import
    import java.util.Date;
    import java.sql.PreparedStatement;
    import java.util.GregorianCalendar;
    As far as I know if I have import the above like
    import java.util.*; then it means I can use any classes in java.util ,but if I am not importing
    import java.util.GregorianCalendar;
    import java.util.Date;
    my program is giving error.Can somebody tell me,where my concept is wrong.
    Thanks

    import java.sql.*;
    import java.util.*;
    //import java.util.Date;  // <-- needed to avoid "the type Date is ambiguous"
    public class PackageEg {
        public static void main(String[] args) {
            Date test = new Date();
    }This code gives an error when I compile it, but if I include the
    java.util.Date import it is good. The reason is that there are two
    possible Date classes - one in java.util and one in java.sql. The
    compiler cannot figure out which one I mean.
    If I include a specific class like java.util.Date, then this one will be used
    in preference to any .* imports. (These are called "imports on demand")
    This explains why you need java.util.Date, but the other two are a
    mystery. As far as I know PreparedStatement and GregorianCalander
    are unique names within the packages you mention. Could you post
    some code that will not compile unless the specific import statements
    are there?

  • Java.util.Calendar calculates wrong date when any duration is added

    Hi friends,
    I am trying to calculate the date through java.util.Calendar object and getting wrong value. Let me explain the scenario -
    Scenario1:
    I have taken start date and added some duration to that and expecting a new date which should be calculated as (start date+ duration). The value is as below -
    start date = 2012-01-09 (9 January 2012 )
    duration = 1year, 1month, 20 days
    new date = 2013-02-28 ( 28 February 2013)
    *Here new date I am expecting is 2013-03-01 (1 March 2013).
    Scenario2:
    I have taken another set of values as below -
    start date = 2011-02-15 (15 February 2011)
    duration = 1year, 1month, 15days
    new date = 2012-03-30 (30 March 2012)
    *Here new date is as expected.
    Scenario1 data is giving me wrong result. Please let me know if any more information is required. Any help will be appriciated. Thanks in advance.
    Edited by: user560316 on ९ जनवरी, २०१२ ६:२३ अपराह्न
    Edited by: user560316 on ९ जनवरी, २०१२ ६:२४ अपराह्न

    It all looks pretty straightforward to me. Try running the following code:
    public class TestCalendar {
        public static void main(String[] args) {
            java.util.Calendar myDate = java.util.Calendar.getInstance();
            java.text.DateFormat df = new java.text.SimpleDateFormat("dd MMMM yyyy");
            myDate.set(2012, java.util.Calendar.JANUARY, 9);
            System.out.println("Start date = " + df.format(myDate.getTime()));
            myDate.add(java.util.Calendar.YEAR, 1);
            myDate.add(java.util.Calendar.MONTH, 1);
            myDate.add(java.util.Calendar.DAY_OF_MONTH, 20);
            System.out.println("End date = " + df.format(myDate.getTime()));
    }This gives the following result:
    Start date = 09 January 2012
    End date = 01 March 2013

  • Java.util.vector value to String

    Hi
    I am trying to use some API calls for securecomputing. One of the value when i print using API, i get the result as
    java.util.Vector$1@93d6bc
    How do i convert this value into readable string format.
    Thanks for any help
    Joseph

    Even after adding toString() it still returns the
    same value.
    System.out.println("Role " +
    (user.getValue(User.IDS_ROLE)).toString());
    Returns "Role java.util.Vector$1@93d6bc"
    User.IDS_ROLE is an int
    Thanks for the repliesWe didn't mean for you to explicitly call toString(), we meant for you to implement it. What kind of class does user.getValue(int) return? Surely it's not a java.util.Vector, but something else - what it is returning looks confusing (java.util.Vector$1...)

  • Files creatd in Unix through java, URGENT

    Hi,
    While creating files in unix through Java, by default created files have only permission:
    -rw-r--r--, actually I need full permissions(-rwxrwxrwx ) for the files created through java in unix. Any idea how can we do this?
    Your help would be greately appriciated.
    Thanks,
    Anand

    I doubt that you will be able to get execute permissions set on normal files by setting the umask. You may have to use Runtime.exec() to invoke chmod, or call chmod via JNI if it is something you do often.

  • Problems with java.util.zip

    I've got a odd problem here. I'm not sure if this is the appropriate forum but I couldn't find anyplace more appropriate.
    So the problem is...
    I create my ZIP file and if I open it in WinZip, no problem. But if I open the ZIP file using the 'Compressed Folders' feature of Windows Explorer I don't see any of the files. As far as I can tell, if the files I ZIP up do not contain any path information then they open fine via 'Compressed Folders'.
    Is this a bug in java.util.zip? Or is the 'Compressed Folders' feature in Windows Explorer half-baked?
    And finally is there any way for me to not include the path information of the files added to ZIP?
    Thanks.

    Looce:
    I'm more than willing to modify things.
    But I'm still curious why WinZip and Windows are treating the ZIP files differently.
    Also, the only way I can figure to get the files into the ZIP without the path information being stored in the ZIP file is by copying the files to the directory containing my application jar file and then passing in the file name without the path being specified. That is the only way FileInputStream would be able to find the files without including path information. This seems like a lot of unnecessary overhead.
    Another oddity is that if I create the ZIP archive using the file path for the FileInputStream and view the ZIP file using a HEX editor the entire path is being stored including the drive letter. But if you view the file using WinZip the path field seems to be removing the drive letter and only displaying the path. On top of that, even though the drive letter is contained in the archive if you unzip the file using WinZip it ignores the drive letter and unzips the file to whatever drive the archive is located on. In the grand scheme of things it makes sense for WinZip to ignore the drive letter.
    Thanks for you help anyways.

  • Problem in clustering in Weblogic 5.1 (java.util.zip.ZipException)

    Hi All,
    We are using WLS 5.1 clustering. 2 WLS are running in 2 different unix box in same subnet. But we are getting the following exception ( Though all the Beans have been deployed successfully).
    java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.open(Compiled Code)
    at java.util.zip.ZipFile.<init>(Compiled Code)
    at java.util.zip.ZipFile.<init>(Compiled Code)
    at weblogic.boot.ServerClassLoader.deploy(ServerClassLoader.java:132)
    at weblogic.cluster.AnnotatedServiceOffer.expandClassPath(Compiled Code)
    at weblogic.cluster.AnnotatedServiceOffer.readObject(Compiled Code)
    at weblogic.common.internal.WLObjectInputStreamBase.readPublicSerializable(Compiled Code)
    Fri Jan 25 16:57:22 MST 2002:<E> <MulticastSocket> Multicast socket receive error: java.lang.RuntimeException: I/O error opening JAR file from file:/opt/wlogic/weblogic/obscluster/server113/tmp_deployments/ejbjar-4247.jar
    (cluster name we have changed to obscluster )
    This Exception is coming in both the servers The difference is that the server whose ip ends with 112 is trying to open the file from server113 dir and the server whose ip ends with 113 is trying to open the file from server112 dir.
    In web I have found that if the directory structure of 2 servers doesn't match then this porblem can arise. But for both of my servers the directory structure is same , at least until /opt/wlogic/weblogic/obscluster/ and then the directory server113 or server112 is created by Weblogic automatically when I have started the Server.
    Any help regarding this will be very helpful.
    Thanks & Regards
    Srijeeb.

    Hi everyone,
    I think I have got the solution. Using sp11. added sp11 related jar in PRE_CLASSPATH . Problem Solved....
    Thanks
    Srijeeb

Maybe you are looking for

  • Flash builder 4  compatible   myeclipse and  spring

    Hi , i  did a project  using  flex 3 , spring 2.5 and  myeclipse 6.6  ,  i want to migrate it  to new  flash builder 4 . can some one  explain  what are "compatible  versions of  myeclipse  and  spring " for flash builder  4

  • Creating DVD-ROM content?

    Premier Pro CS3, Windows XP, 2GB RAM, plenty fast hard drives I'd like to create a DVD with both video and DVD-ROM content. Is that possible? If not, then suggestions for the following ... part of the DVD is video content in the form of slide shows s

  • Installing the SSIS Connectors v2.0 for Oracle by Attunity - SSIS 2012

    Hi, on a SQL Server 2012 I'd like to add the SSIS Connectors vers. 2.0 for Oracle. To accomplish this task I've tried this white paper: http://technet.microsoft.com/en-us/library/ee470675(v=sql.100).aspx but it is referred to SQL Server 2008. In orde

  • TS1702 Assistance- Numbers Apple App

    Hi, Please do assist, whenever I try to open an excel file using numbers I keep getting an error message "spreadsheet couldn't be imported, out of memory" how do I resolve this???

  • I am unable to update to ios 8.3 ..

    I am unable to update to ios 8.3 over wifi....I keep on getting a message saying that an error occurred while updating. Can anyone offer any help?