i used exe4j to turn my java app to exe. the thing, when i ran the exe in my pc it worked but when i ran it on a diff pc it didnt. just a certain function of the program i created didnt work.
the app is simple. i enter the full path of a .doc or .docx file (any ms word file). I press a button and the app opens that document and prints the first paragraph. Sun already has code/libraries for text documents but when it comes to microsoft word documents and other office files, no such thing existed. After some reading I saw that I needed to download libraries that apache built. I did. I edited my code accordingly.
When I ran exe4j, I added the jar files (part of the files located in the apache poi folder) that my app needed and I ran the generated exe file.
That's it. When I tried running it on my pc again after finding out it didnt work on adiff laptop, I don't know how it occured to me, but I decided to delete the folder that had the jar files. I figured it didnt matter because my exe already has everything it needs. But I was wrong. Soon as I deleted the folder and ran the exe file again, it didn't work. When I checked the generated errorlog file I saw the exception CLASSDEFNOUTFOUND error. I already msged the site where I downloaded exe4j from.
What does this mean? Because the jar files weren't part of Sun's production then wherever that exe file goes, the folder must follow as well? :S
Anyone here can recommend a java2exe file they used and had no problems with? thanks
Without going into the problem: why did you make it an exe? Why not just run is as a Java application?
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Joined: Sep 27, 2009
java apps run in 3 ways. exe, jar, and from ide. all 3 cases require jvm present. im sorry, what do you mean? i think i fixed my prb. i decided i'd try jar but i didnt no how to turn it to jar and after a lot of reading i discovered that netbeans prepares a jar file in the dist folder of the project folder. so i used a prg called jar2exe. i added the generated jar file and the two jar files tht i needed for my app and created the exe file. it worked. i deleted the folder. it worked! im about to try it on a different laptop. but please do tell me what you meant and how i could have done that.
Ehm no. you execute a Java program with java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file). Your IDE will probably invoke it in that way.
My question is why are you converting your Java application to an exe? Why are you using jar2exe and exe4j?
Oh ok I think I got it. Well basically, everytime I want to run this program I'll need the console to use it? The files have to move with me wherever I go. With an exe program, it's just one file which can run anywhere so long as there's jre.
EDIT: ya I understand. Platform independant so you can run it on any platform. it's just something I wanted to try that's all.
author and jackaroo
Like I said, after some reading i discovered that instead of installing ant and going through hell, that my ide, netbeans already prepares a jar file for me
I'd like to ask a different question please. I read somewhere that Sun doesn't have the libraries needed to reading ms documents but apache does; poi. Is there a version limit on it? I'm running the app on a different laptop that has ms 2007 running and it's not printing anything.
author and jackaroo
Leo Max wrote:Like I said, after some reading i discovered that instead of installing ant and going through hell, that my ide, netbeans already prepares a jar file for me
Yes, but you then went on to say that you were converting that Jar file into a Microsoft-only exe, which just seems like a broken concept.
Leo Max wrote:I'd like to ask a different question please. I read somewhere that Sun doesn't have the libraries needed to reading ms documents but apache does; poi. Is there a version limit on it? I'm running the app on a different laptop that has ms 2007 running and it's not printing anything.
According to Apache POI - HWPF they support the Microsoft Word 97(-2007) file format, however it is still in early development.
Joined: Sep 27, 2009
well it's working on my pc and laptop now. whe ni open 2003 ms word it works. but no luck with 2007. i thought it would work since they said 97-2007. well at least i got it to work. i went tback to using exe4j and this time i added the jar file (generated by ide) and the 2 jar files from poi and it worked just as well. guess that answers my question then.
alas 2007 isn't supported. either that or im doing something wrong again
Any thoughts btw? When I enter the location of the ms 2007 docx file, it shows nothing. but when i show it a doc created by 2003 it shows me whts inside.
EDIT: im here now reading webpage and it says that i need a diff package for 2007? instead of hwpf i need xwpf. but i cant find it when i type the import line. import org.apache.poi.xwpf doesnt exist >.>
EDIT: found it! i totlaly forgot that for the import lines to work i needed to right click on the prj-properties-libraries-add jar/folder. the jar file needed for 2007 is poi-ooxml-3.8-beta3-20110606.jar
well this was fun. We all learned something. Thank for your help. And yes, it's still in it's early stages. The method I use to print the contents doesn't help me if I wanted to get them one line at a time so I need to write some workaround code.