I am a little bit confused. I created an executable jar file from a program I made. My program is around 100K in size, 57K when converted to jar.
The issue is I sent my program to a couple of friends who were using Windows 7. I made my program using Windows XP, and I made it in Notepad.
My friends downloaded the program online. They opened it. My first friend, seconds after running my program, had her computer freeze. When she turned it back on Windows wouldn't start and we ended up having to do a system restore.
My second friend, the program worked fine, but the issue was that when she closed it... she tried going to her Downloads folder, only to find that she could no longer access it. The error message was: "This file does not have a program associated with it for performing this action. Please install a program, or if one is already installed, create an association in the Default Programs control panel".
I scanned my program with an antivirus and it came out clean.
I went over my program and checked to see the most "dangerous" operations I could find, which turned out to be simply writing bytes from a file and also reading bytes from a file (a file with a custom extension).
There was also an invokeLater call. But that's about the most "dangerous" stuff I could find. The rest of my program was basically manipulating my custom classes... working with my Swing GUI components, among other things.
I am copy pasting the code of the program that executes when the program starts. When it ends it basically saves a bunch of bytes into the same file.
I don't think I want to paste my whole program or even paste all of the operations that my program does, because it is pretty long and I honestly have no clue why it would cause Windows to crash, or to cause an error (like the Downloads folder one).
The worst part about this is that I don't really have a computer I can test this error on. It has just happened to two of my friends, I feel hesitant to send it to more lest similar stuff happen.
Also, I sent this program to a friend using Windows XP and nothing bad happened. Another friend using Windows Vista opened it and ran it fine, without anything bad happening as well.
If you have any idea what may be going on please let me know. Also... if you have any idea HOW TO GO ABOUT SOLVING THIS please let me know as well... Since right now I am pretty much stuck in "Wow, I can't give this program away anymore unless I fix this issue. But I can't fix this issue because I don't have my own Windows 7 computer that I can test this stuff on."
Here are some code snippets which is what I remotely assumed could cause a problem, even though I don't know why it should. Also, if you think that manipulating Swing objects or manipulating class variables of custom made classes, or some parsing operations, could cause problems, let me know and I will post some snippets.
Much help would be appreciated.
SwingUtilities.invokeLater(new Runnable() { public void run() { textarea[index].setCaretPosition(textarea[index].getDocument().getLength()); } }); }
File file = new File("data.ni1"); try{ boolean success = file.createNewFile(); } catch(IOException e){} File fileToLoad = file; byte[] bytes = new byte[1]; try{ InputStream in = new FileInputStream(fileToLoad); in.read(bytes); in.close(); } catch(IOException e){} //I modify the byte array by subtracting a number from each byte) for(int i = 0; i<bytes.length; i++){ bytes[i] = (byte)(bytes[i] - 100); } //I convert the result to UTF 16 string String contents = new String(bytes, "UTF-16"));
Also, if this info helps at all, I downloaded an antivirus and ran a full scan on my system shortly after this happened. It detected 14 spyware files on my computer (in my cookies). However, my jar file itself was still scanned as clean. Of course, I created the jar file before I ran the antivirus so I don't know if remaking the jar file from the same class files would make any difference?