Solved

Detaching my java application from openoffice leaving it open

Posted on 2009-05-18
9
411 Views
Last Modified: 2013-11-13
Hello guys!

I'm facing the following problem: in my java application I need to open an openoffice calc spreadsheet, populate it with my data and then detach from OOo leaving the spreadsheet open on screen (this is mandatory, since the user expect to get an OOo calc open with certain data exported from my application, and then work with this data on calc).
I managed to get everything working (calc opens filled with data) but I don't understand how can I detach this calc window from my java app.

It seems that the communication bridge between java and OOo creates a new thread. When the user closes the java application, the JVM won't stop until all OOo instances are closed. I suspect that the java-OOo "bridge" live thread prevents the JVM to fully stop. Googling around the only way I found to detach is to stop OOo, but this is not what I want. OOo must stay open and fully detached from Java.

Any ideas? Thanks in advance.
0
Comment
Question by:uuderzo
  • 5
  • 4
9 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 24409717
>>It seems that the communication bridge between java and OOo creates a new thread

If your theory's correct, then try 'finding' that thread and interrupting it. Yes, that's an unfortunately low-level way of approaching it, but if the 'bridge' won't allow that via the api, then i can't think of another way
0
 

Author Comment

by:uuderzo
ID: 24409868
To give you more infos, my java app shouldn't close just after the export operation. The java app is a huge rich client J2EE application lauched via Java Web Start that usually keeps open all the day on user client machine (somethimes the application is closed and re-opened many times).

What I need is to communicate with OOo only for the time needed for the export operation, then detach. Both Java app and OOo keep open. My concern is because so many customers use it and I fear to receive many and many phone calls asking me why processes does not go down. I know that this is a difficult situation to obtain, since people probabily won't be aware of the existence of many unterminated JVMs... but usually users don't kill the OOo quickstart process (that keeps the bridge thread alive) and when you deal with such big apps every aspect can be a trouble.

I fear i'll not be able to find the right thread to stop. I must investigate further on this possibility.

Anyway, I'm looking for a UNO based solution (Universal Network Objects).
0
 

Author Comment

by:uuderzo
ID: 24410144
Tried to stop the tread. Nothing. Even System.exit(0) won't shut down the JVM.
This UNO bridge thread is really tough to know off.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 86

Expert Comment

by:CEHJ
ID: 24410478
Have you thought about starting another JVM for the export?
0
 

Author Comment

by:uuderzo
ID: 24410547
I don't see the point in doing that. If the main or a secondary JVM doesn't shut down, the problem is the same for me.

Anyway, all my tests were performed on a simplified app lauched through a main method from the development environment. When I close the test frame, the dev environment shows me that the process is still on and closes only when I shutdown OOo.

Today I tried with the real application launched through JWS and it seems that the process goes down even if OOo is up. I don't know the reason of this different behavior, but this could lead to a non-problem. If the production environment works, I'm happy.

I'm still testing other cases, then bring back here for a conclusion.
0
 

Author Comment

by:uuderzo
ID: 24413232
Mmmmh... not so simple. Keeping the connection bridge opened after my export operation causes malfunctioning of other parts of the java application (developed by others) that deal with OOo in other way. Sounds like I must find a way to break the connection between java and OOo just after terminating my export.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
ID: 24413627
>>I don't see the point in doing that. If the main or a secondary JVM doesn't shut down, the problem is the same for me.

Well i was thinking at least you could close down the gui - but i take your point ;-)

afaicr there's a way of using TCP/IP to bridge is there not? That could obviate the coupling of processes
0
 

Author Comment

by:uuderzo
ID: 24419994
Your hint was really helpful.

Instead of working at XDesktop level I found a solution (http://www.oooforum.org/forum/viewtopic.phtml?t=35602) that works at XConnection level. That worked for me, other code now works still well also after my export operation.

Thank you for your support!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24420315
That's great :-)

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
simplest php form 3 77
even odd program using while loop 3 40
How to convert from xls to xlsx using java 7 36
eclipse console opening separately 2 16
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question