• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.exe has generated errors and will be closed by windows (j2sdk1.4.0 on win2000)

 
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there

I first posted this on the IO forum thinking that the error was on my file handling.

I am getting the error "java.exe has generated errors and will be closed by windows."

I did some research to find that the error was known for instances on java 1.1 and 1.2 when using a Pentium 4 processor. And was not specific to file handling code. I am trying to find out if anyone has information about this error occuring on 1.4.0 or 1.4.2 on windows 2000 using a celeron processor. And most importantly, how I can get around it.

Thanks,
Rachel
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you find the created lock-file (mentioned in I/O)?
Can you show us the code - I might test it under linux.
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The created lock file? Or the log file? What exactly do you mean and where can I find it?

As for the code, I'll work on taking it out of the gui it's in at the moment and I'll post it when it's less reliant on so much other code.

Thanks!
rachel
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll first give you a pseudo version so you can see what the code is doing.

A user opens up the email screen. Each email is assigned a number. When the user attaches files, the files are renamed according to the email number. When the user sends the message, the attachment files are renamed in the same location to reflect the email number and the attachment number within that email. (I have come up with a different way to approach this. I'm going to try renaming the files to the correct name from the start. But I still would like to know why this gives the java.exe error)


Code for when attachments are added to the email:
private void handleAttach(){

fileChooser = new LFileChooser();
fileChooser.setApproveButtonText(Utils.getLabel
("Buttons_FileChooser_Attach"));
int option = fileChooser.showOpenDialog(this);
if(option == JFileChooser.APPROVE_OPTION){
if(fileChooser.getSelectedFile()!=null){

File destinationFile = new File(FolderLocations.MailAttachmentsLOCATION, "out"+thisEmail.getEmailNumber()+"_"+fileChooser.getSelectedFile().getName());
File sourceFile = fileChooser.getSelectedFile();

moveFiles(destinationFile, sourceFile);

}
}
}

//moveFiles moves the files from the source to the destination.


Code when the email gets sent:

public void save(){

//big date thing is for calculating the sting of the datetime the email was sent

Calendar timeNow = Calendar.getInstance();
int day = timeNow.get(Calendar.DAY_OF_MONTH);
int month = timeNow.get(Calendar.MONTH) +1;
int year = timeNow.get(Calendar.YEAR);
int hour = timeNow.get(Calendar.HOUR_OF_DAY);
int min = timeNow.get(Calendar.MINUTE);
int second = timeNow.get(Calendar.SECOND);

String days;if(day<10) days = "0"+day;else days = day+"";
String months;if(month<10) months = "0"+month;else months = month+"";
String hours;if(hour<10) hours = "0"+hour;else hours = hour+"";
String mins;if(min<10) mins = "0"+min;else mins = min+"";
String seconds;if(second<10) seconds = "0"+second;else seconds = second+"";

dateTime = days+"/"+months+"/"+year+" "+hours+":"+mins+":"+seconds;

finalizeAttachments();

EmailHandler eh = new EmailHandler(this);
eh.sendToOutbox();
//sendToOutbox - writes a line in a text file and saves the next email number to a properties file (two different files).
}

public void finalizeAttachments(){


int attachmentNumber = 0;
String attachNumber = "";

for(int i=0; i<emailAttachmentsVector.size(); i++){

File tempFile = (File)emailAttachmentsVector.get(i);

String tempFileNameOrig = tempFile.getName();
String tempFileNameNew = tempFileNameOrig.substring(tempFileNameOrig.indexOf("_")+1, tempFileNameOrig.length());
String tempFileName = "out"+thisEmailNumber+"l"+i+"_"+tempFileNameNew;


File newFile = new File(tempFile.getParent(), tempFileName);

boolean success = tempFile.renameTo(newFile);
System.out.println(success+" "+newFile.getPath());

attachmentNumber = i+1;
if(attachmentNumber < 10) attachNumber = "0"+attachmentNumber;
else attachNumber = attachmentNumber+"";
attachments += tempFileNameNew+":"+attachNumber;

if(attachmentNumber<emailAttachmentsVector.size()) attachments += "|";

}
}


If there's more that you would like, just ask.
Cheers.
Rachel
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I have the problem in another place too.

public void readyToLeaveFrame(){

int currentEmailNumber = thisEmail.getEmailNumber();
String currentEmailString = "out"+currentEmailNumber+"l";

thisEmail = null;
System.gc();

File deleteThisFile;

File AttachmentFolder = new File(myFilePath);

String[] stringFileArray = AttachmentFolder.list();

if(stringFileArray == null){
this.hide();
this.dispose();
}

if(stringFileArray.length!=0){
for(int k = 0; k<stringFileArray.length; k++){
deleteThisFile = new File(AttachmentFolder+"/"+stringFileArray[k]);

String filename = deleteThisFile.getName();
if(filename.indexOf(currentEmailString)!=-1){
boolean success = deleteThisFile.delete();
System.out.println(success);

}

}}


this.hide();
this.dispose();
}



I am starting to suspect that it is a memory error. Maybe java is eating too much memory and that makes file handling requests just too much for it to handle?

So how would I find out if Java is using too much?

Cheers,
Rachel
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic