INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

how to open and import files in Zeves within Java

how to open and import files in Zeves within Java

how to open and import files in Zeves within Java

(OP)
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

RE: how to open and import files in Zeves within Java

You will need to provide more details: open the file for what? What do you mean with "import a file"?

Cheers,
Dian

RE: how to open and import files in Zeves within Java

(OP)
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

RE: how to open and import files in Zeves within Java

(OP)

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());                   }

RE: how to open and import files in Zeves within Java

Have you read my response to your thread of the same problem?
    http://www.tek-tips.com/viewthread.cfm?qid=1637183&page=1

I did not post it lightly. You need to wrapper the path to pyw file with quotes because the path contains spaces.

String[] cmd = {"C:\\Python23\\pythonw.exe", "\"C:\\Program Files (x86)\\Z-Eves 2.3.1\\gui\\toplevel.pyw\""};   

RE: how to open and import files in Zeves within Java

@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: http://home.arcor.de/hirnstrom/minis/index.html

RE: how to open and import files in Zeves within Java

(OP)
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";
 

RE: how to open and import files in Zeves within Java

(OP)
my file path is like this one:
C:\Users\irou\Desktop\exemple.tex

RE: how to open and import files in Zeves within Java

@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.

RE: how to open and import files in Zeves within Java

@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: http://home.arcor.de/hirnstrom/minis/index.html

RE: how to open and import files in Zeves within Java

(OP)

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

RE: how to open and import files in Zeves within Java

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: http://home.arcor.de/hirnstrom/minis/index.html

RE: how to open and import files in Zeves within Java

(OP)
@stefanwagner
My file path is C:\Users\USER\Desktop\exemple.tex

what shall i write exactly in shell :
I have this: C:\Users\USER>

RE: how to open and import files in Zeves within Java

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: http://home.arcor.de/hirnstrom/minis/index.html

RE: how to open and import files in Zeves within Java

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close