Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to open and import files in Zeves within Java

Status
Not open for further replies.

irou

Programmer
Feb 5, 2011
10
TN
Hello,
this code let me execute Z\eves within java, but now, i want to open a file and to import an other one.
Code:
String[] cmd = {"C:\\Python23\\pythonw.exe", "C:\\Program Files (x86)\\Z-Eves 2.3.1\\gui\\toplevel.pyw"};                    File workingDir = new File("C:\\Program Files (x86)\\Z-EVES 2.3.1\\gui");try   {  Runtime r = Runtime.getRuntime();  Process p = r.exec(cmd, null, workingDir); }catch(Exception e1) {                       System.out.println("erreur d'execution " +  e1.toString());                   }
Please, how can i do that
thank you
 
You will need to provide more details: open the file for what? What do you mean with "import a file"?

Cheers,
Dian
 
I'm developping an application with java.
It's about transforming an XML schema to Z specification.
So,I have to generate a .tex file(after transformations done with XSLT.
In my editor, i have to execute Z/Eves and open this file(.tex): It means I have a button TRANSFORM(on click) Z/eves is executed and specification written in the file (.tex)is opened.

I wish that's clear now
 

my problem here is how to complete this code to open my file .tex like when i want to open a file with notepad for exemple i do that
Code:
 Runtime.getRuntime().exec("C:\\Program Files (x86)\\Notepad++\\notepad++.exe "+file.path);
here, where should i insert the file path
Code:
String[] cmd = {"C:\\Python23\\pythonw.exe", "C:\\Program Files (x86)\\Z-Eves 2.3.1\\gui\\toplevel.pyw"};   
 File workingDir = new File("C:\\Program Files (x86)\\Z-EVES 2.3.1\\gui");
try   { 
 Runtime r = Runtime.getRuntime();  
Process p = r.exec(cmd, null, workingDir); 
}catch(Exception e1) {                      
 System.out.println("erreur d'execution " +  e1.toString());                   }
 
Have you read my response to your thread of the same problem?

I did not post it lightly. You need to wrapper the path to pyw file with quotes because the path contains spaces.
[tt]
String[] cmd = {"C:\\Python23\\pythonw.exe", "[highlight]\"[/highlight]C:\\Program Files (x86)\\Z-Eves 2.3.1\\gui\\toplevel.pyw[highlight]\"[/highlight]"};
[/tt]
 
@tsuj:
If you have a Program a.exe and want to pass as argument a file b.txt, maybe using an option "-x 3", and you put it into one, big String, then you have to take care to mask your blanks:

Code:
"c:/program files/a.exe -x 3 d:/my data/b.txt"
will not work.
But if you put every part in a separat Sting, it should work:
Code:
cmd = {"c:/program files/a.exe", "-x", "3", "d:/my data/b.txt"};
@irou: Your filepath shall be the 3rd string in cmd, as far as I can tell.
Code:
String[] cmd = {"C:\\Python23\\pythonw.exe", "C:\\Program Files (x86)\\Z-Eves 2.3.1\\gui\\toplevel.pyw", "Y:/our/file.path"};
Instead of two backslashes you may use single forward slashes.


don't visit my homepage:
 
this code is correct and it allows me to execute Z\eves
Code:
String[] cmd = {"C:\\Python23\\pythonw.exe", "C:\\Program Files (x86)\\Z-Eves 2.3.1\\gui\\toplevel.pyw"};    File workingDir = new File("C:\\Program Files (x86)\\Z-EVES 2.3.1\\gui");try   {  Runtime r = Runtime.getRuntime();  Process p = r.exec(cmd, null, workingDir); }catch(Exception e1) {                       System.out.println("erreur d'execution " +  e1.toString());                   }
Now,I want to open this file (.tex) when Z\eves is executed,where should i insert my file's path?

Code:
String cheminfichier=ExportVersXML.path+".tex";
 
my file path is like this one:
C:\Users\irou\Desktop\exemple.tex
 
@stefanwagner: But that is clearly intended to be the first argument being the full path pointing to a pyw file, and that is needed as far as the cmd window on windows os. Well, I pass and it needs only a simple test to establish the need.
 
@irou: How could you start your program from the windows shell?

Code:
pythonw "C:\\Program Files (x86)\\Z-Eves 2.3.1\\gui\\toplevel.py" "C:\Users\irou\Desktop\exemple.tex"

@tsuji: You mean that pythonw needs the masking? Maybe. On Linux I open the file in "Ubuntu One" simply like this:

Code:
String[] cmd = {"/usr/bin/gedit", "/home/stefan/Ubuntu One/triangles.txt"};   

File workingDir = new File ("/home/stefan/proj");
try   
{  
	Runtime r = Runtime.getRuntime ();  
	Process p = r.exec (cmd, null, workingDir); 
}
catch (Exception e1) 
{                       
	System.out.println ("erreur d'execution " +  e1.toString ());
}

If you use the shell to execute such a program, so that you have another layer of indirection, you will need the masking ('start -c "Co mand"').

don't visit my homepage:
 
Code:
String[] cmd = {"C:\\Python23\\pythonw.exe", "C:\\Program Files (x86)\\Z-Eves 2.3.1\\gui\\toplevel.pyw", "C:/Users/USER/Desktop/exemple.tex"};
				  
 File workingDir = new File("C:\\Program Files (x86)\\Z-EVES 2.3.1\\gui");
  try  {
	 Runtime r = Runtime.getRuntime();
					  
	r.exec(cmd,null , workingDir);
			         
 }catch(Exception e1) {
				     
System.out.println("erreur d'execution " +  e1.toString());
				   }
I try with this code, Z-eves is executed but there is no file, it means my file is not opened
My file should be there in cmd or no?
I don't understund what cmd shoud contain
I tried all possiblilities but My file is not opened
 
Your file is constantly changing. Now in C:/Users/USER/Desktop, before in
C:\Users\irou\Desktop\exemple.tex - where is it?

As far as I understand
Code:
String[] cmd = {
  "C:\\Python23\\pythonw.exe", 
  "C:\\Program Files (x86)\\Z-Eves 2.3.1\\gui\\toplevel.pyw",
is correct so far?

In the windows menu, there is an entry 'Run command' or the like. If you insert cmd there, you get a shell.

Test String[] cmd = {
"C:\Python23\pythonw.exe"
"C:\Program Files (x86)\Z-Eves 2.3.1\gui\toplevel.pyw" "C:\Users\irou\Desktop\exemple.tex"
[/code]
there, or whatever the path to your tex-file is. Use single backslashes in the shell.

Does it work? If yes, translate the path of the texfile to java (double backslash or single slash forward). If not - what's the error? The error-message?

Report the exeption, if there is one.



don't visit my homepage:
 
@stefanwagner
My file path is C:\Users\USER\Desktop\exemple.tex

what shall i write exactly in shell :
I have this: C:\Users\USER>
 
I'm sorry, the formatting was broken, and I didn't realize it.

You shall write your 3 strings, masked with ", the first being the full path of pythonw.exe, the second the python script toplevel.pyw and the third one the tex-file, where ether it is.
Code:
"C:\Python23\pythonw.exe" "C:\Program Files (x86)\Z-Eves 2.3.1\gui\toplevel.pyw" "C:\Users\USER\Desktop\exemple.tex"

Don't produce a manual linebreak - I didn't, it might be the weblayout.

don't visit my homepage:
 
I write this but nothing is executed or written.there is no error but nothing happens.
Code:
"C:\Python23\pythonw.exe" "C:\Program Files (x86)\Z-Eves 2.3.1\gui\toplevel.pyw" "C:\Users\USER\Desktop\exemple.tex"
I try all possibilities with slashes and backslashes and when Z-Eves opened there is no file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top