wood burning stoves 2.0*
The moose likes Java in General and the fly likes problem turning to exe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "problem turning to exe" Watch "problem turning to exe" New topic
Author

problem turning to exe

Leo Max
Ranch Hand

Joined: Sep 27, 2009
Posts: 36
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
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

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.
Leo Max
Ranch Hand

Joined: Sep 27, 2009
Posts: 36
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.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

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?
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11460
    
  94

Or to put it a totally different way.

While it is a Java application, you can run it on your Microsoft operating systems, a Macintosh system a Linux system, an AIX system, ....

Since you are converting it to a Microsoft-only exe file, you are reducing the potential usefulness of it.

So why do it?


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Leo Max
Ranch Hand

Joined: Sep 27, 2009
Posts: 36
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.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11460
    
  94

Leo Max wrote:Well basically, everytime I want to run this program I'll need the console to use it?

Nope - most operating systems understand the concept of executable jar files, and will run them if you double-click on the associated icon.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Then just create a jar.
Leo Max
Ranch Hand

Joined: Sep 27, 2009
Posts: 36
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.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11460
    
  94

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.
Leo Max
Ranch Hand

Joined: Sep 27, 2009
Posts: 36
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.
 
 
subject: problem turning to exe