• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem to rin openoffice

 
Kaleeswaran Karuppusamy
Ranch Hand
Posts: 155
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..........
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 Karuppusamy
Ranch Hand
Posts: 155
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 96
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How exactly are you calling exec() ?
According to the error message ("\soffice"), you call it wrong.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 Karuppusamy
Ranch Hand
Posts: 155
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
" 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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 Karuppusamy
Ranch Hand
Posts: 155
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47300
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mkae sure to redirect the ProcessBuilder's error Stream too.
 
Jon Parise
Ranch Hand
Posts: 81
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic