aspose file tools*
The moose likes Java in General and the fly likes problem to rin openoffice 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 to rin openoffice" Watch "problem to rin openoffice" New topic
Author

problem to rin openoffice

Kaleeswaran Karuppasamy
Ranch Hand

Joined: Jul 19, 2007
Posts: 154
i have the program to run open office.when its running in eclipse ide my program running without any error.when i am trying to run in command prompt it will not running.i restarted my computer i am tried to run my program in command prompt it did not run but the same time once i run my program in eclipse after that i am trying to run same program in command prompt now working....what is the reason in eclipse working but command prompt not working please suggest me..........


Judge a man by his questions rather than his answers --Voltaire
SCJP 1.5 97%
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42946
    
  70
when i am trying to run in command prompt it will not running.

What does this mean - what exactly happens? Are any (error) messages being displayed?

Do I understand correctly that you have a Java program that attempts to start OpenOffice? If so, how does it do this - using Runtime.exec or ProcessBuilder?
[ June 03, 2008: Message edited by: Ulf Dittmer ]
Kaleeswaran Karuppasamy
Ranch Hand

Joined: Jul 19, 2007
Posts: 154
java.io.IOException: Cannot run program "\soffice": CreateProcess error=2, The system cannot find the file specified
java.io.IOException: Cannot run program "\soffice": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)



this is the error dispaly i First time i heard the name ProcessBuilder.however i know Runtime.getRuntime().exec()..


Anyway this error occure inside my jar file class even i cannot customize and decompile my code because it has usedd deprecated java keys label(L1: and goto keys in java).so my compiler not compile this code.

actaully soffice.exe and soffice.bin located inside "D:\OpenOffice\OpenOffice2.3\program" this folder and i set path and classpath to this but the error is same....how solve this problem

please help me
David Balažic
Ranch Hand

Joined: May 15, 2008
Posts: 89
How exactly are you calling exec() ?
According to the error message ("\soffice"), you call it wrong.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42946
    
  70
I don't understand your remarks about decompilation, and you not being able to compile your code. But the error message indicates that the command you're trying to execute is not recognized correctly ("\soffice" is most certainly not the name of the executable). Make sure you specify complete paths and classpaths on the command line you're executing. The environment variables may not get picked up correctly by the child process.
[ June 03, 2008: Message edited by: Ulf Dittmer ]
Kaleeswaran Karuppasamy
Ranch Hand

Joined: Jul 19, 2007
Posts: 154
" The environment variables may not get picked up correctly by the child process."


you are is absolutely right sir there is the problem in setting environment variable.
but i set environment variable in windows manually and using java api i set in my program also(using system.setproperty()) and i set it as top most class but inner class only has the coding to call "soffice" it will not take. what can i do for ....please i am running out of time please help me...

when i run this program in eclipse working fine and it will create windows process for "soffice" once this process created my program run in command prompt nothing problem...
please suggest me...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42946
    
  70
As I said, whatever environment variables you set may not get picked up. It's better to use a full path as part of the command you're executing. If -for some reason I don't understand- that's not possible, you could put a shell script called "soffice" into the current working directory which starts OO.
Kaleeswaran Karuppasamy
Ranch Hand

Joined: Jul 19, 2007
Posts: 154
Apart from this i have few question i got this code from java2s website

try{
ProcessBuilder launcher = new ProcessBuilder(); Map<String, String> environment = launcher.environment();
launcher.redirectErrorStream(true);
launcher.directory(new File("D:\\OpenOffice\\OpenOffice2.3\\program"));
environment.put("name", "var");
launcher.command("swriter");
Process p = launcher.start(); // And launch a new process
BufferedReader output = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = output.readLine()) != null)
System.out.println(line);
// The process should be done now, but wait to be sure.
p.waitFor();
}catch(Exception e){System.out.println(e);}


using this ProcessBuilder can we embed openoffice into java swing Frame
is it possible..
please suggest me...
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Mkae sure to redirect the ProcessBuilder's error Stream too.
Jon Parise
Ranch Hand

Joined: Jul 03, 2007
Posts: 81
Another option other than hard coding the Open Office path would be to create a config file.

Basically, this would be a text file your program would read to get all it's initial parameters. This way when you upgrade to OO 2.5 or 3 or whatever comes next you don't have to recompile everything.

You would just need to change that file. This is also usually easier than using environment variables.

Just a thought.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem to rin openoffice