Solved

Detaching my java application from openoffice leaving it open

Posted on 2009-05-18
9
404 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
 
LVL 86

Expert Comment

by:CEHJ
ID: 24410478
Have you thought about starting another JVM for the export?
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now