[LITTLE LONG]runtime.exec can't launch link.exe (the linker ofwindows)

  • Thread starter Andrew Thompson
  • Start date
A

Andrew Thompson

I try to launch , in a directory this two command, link.exe (the
linker of windows).


What 'roofs'? I am running XP Pro here,
and there is no link.exe in the 'Program Files'
or 'WINDOWS' directories.

--
Brion T.
PhySci.org


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"This is Preservation Month.
I appreciate preservation.
It's what you do when you run for president.
You gotta preserve."

--- Adolph Bush,
Speaking during "Perseverance Month"
at Fairgrounds Elementary School in Nashua, N.H.
As quoted in the Los Angeles Times, Jan. 28, 2000
 
E

elekis

hi all

I try to launch , in a directory this two command, link.exe (the
linker of windows).

so there my class

import java.io.IOException;


public class Main {

/**
* @param args
*/
public static void main(String[] args) {
ProcessLauncher proc = new ProcessLauncher();
try {
proc.setOutputStream(System.out);
proc.setErrorStream(System.err);
String link = "link";
String arg[]= {link};
int exitVal = proc.exec(arg,null);
System.out.println("Process exitValue: " + exitVal);
System.out.println(arg[0]);
} catch (IOException e) {
e.printStackTrace();
}
}

}



for poeple who wanna know, http://ydisanto.ftp-developpez.com/tutoriels/j2se/runtime/fichiers/ProcessLauncher.java
is the class of process launcher (founded on a other site, this class
work perfecly and are tested.

the funny thing is if I replace link by echo hello world or any other
thing, it"s work and exit value is 0 (so it's good).

but with link or link.exe or C:\... \VB\bin\link.exe (the absolute
path) or cmd.exe /C link.exe, etc...etc..

I just have nothing and the exit value is negatif, there is the output

Process exitValue: -1073741515
link

and I have no idea why , really. I have exacly the same probleme with
cl.exe
techincly I must have

c:\yafl\YDbUpdate>link
Microsoft (R) Incremental Linker Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.

usage: LINK [options] [files] [@commandfile]

options:
etc...
etc...


And I just catch nothing.

So any help would be good and if someone can try this on his computer
and say if he have the same problem.

thanks

a+++
 
A

Andrew Thompson

I try to launch , in a directory this two command, link.exe (the
linker of windows).


What 'windows'? I am running XP Pro here,
and there is no link.exe in the 'Program Files'
or 'WINDOWS' directories.
 
E

elekis

What 'windows'? I am running XP Pro here,
and there is no link.exe in the 'Program Files'
or 'WINDOWS' directories.

sorry, the linker.exe is used to link object module (in c compiler) .
it 's often used with cl.exe .

on my computer, there is where is it.
C:\Program Files\Microsoft Visual Studio 8\VC\bin\link.exe

I thing you can download it womewhere but I don't know where. I ll
looking for.

thanks


a++
 
A

Andrew Thompson

Thanks for clarifying where link.exe cam from.
I do not have that software and won't be installing
it anytime soon, but since I took a closer look at
the problem, it raised another question.
for poeple who wanna know,http://ydisanto.ftp-developpez.com/tutoriels/j2se/runtime/fichiers/Pr...
is the class of process launcher (founded on a other site, this class
work perfecly and are tested.

Really? The source I downloaded at the end
of that link would not compile. Vis.

C:\ProcessLauncher\ProcessLauncher.java:184: unreported exception
java.io.IOException; must be caught or declared to be thrown
process.getErrorStream().close();
^
C:\ProcessLauncher\ProcessLauncher.java:189: unreported exception
java.io.IOException; must be caught or declared to be thrown
process.getInputStream().close();
^
2 errors

I changed it to get it to compile. Did you
make any changes to the source? What?

As an aside, it would probably encourage people
to help you if you could extract the relevant code
from the ProcessLauncher (with acknowledgements
of source, and disclaimer that it is an exact
replica)and put it together with your original
code in an SSCCE*.

* <http://sscce.org/>
 
E

elekis

if you didn't installed it, you probabliy not have, you need it when
you wanna develop in C or C++ under windows.


for the probleme, my trouble is :

I try to do a plug for elcipse and I wanna launch link.exe by clicking
on a button.
the prob is that with link.exe or cl.exe (the cpp compiler for
windows) I have no message

so, I ve made a little example (but yes you have to put try catch in
the file) cause it's not a eclipse probleme.


but I have a better example and easier.


import java.io.IOException;


public class Main {

/**
* @param args
*/
public static void main(String[] args) {
try {
String link = "link";
Process proc = Runtime.getRuntime().exec(link);
try {
proc.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
proc.exitValue();
System.out.println("Process exitValue: " + proc.exitValue());
} catch (IOException e) {
e.printStackTrace();
}
}

}


if you tray that, the exit value return a negative number while in
command line , if I tape link , the link.exe work perfectly.
if you replace String link = "link"; by String link = "echo sdlfkjl";
exit value = 0;

in fact, lot of prog work perfecly execp link.exe and cl.exe


thanks


a+++
 
A

Andrew Thompson

Please refrain from top-posting, and trim
earlier parts of posts that are no longer
relevant. Especially when replying to a
moronic sociopath who is *impersonating*
me. ;-)

but I have a better example and easier.

Yes. This is the sort of code I was talking
about.
import java.io.IOException;

public class Main { ...
        public static void main(String[] args) {
                try {
                        String link = "link";
                        Process proc = Runtime.getRuntime().exec(link);

It is generally considered better to use the
ProcessBuilder class, I cannot recall why.
Search the group for references to it and the
discussions.

(Also, try to keep the line width shorter, so
it does not get line-wrapped by newsclients
and risk causing compilation errors.)
                        try {
                                proc.waitFor();
....

Another thing to account for are the output
streams for the standard and error output.
The first code you posted, implied that the
linked class took care of those (though I did
not check how). For a reliable run, this
code needs to do that as well.
 
D

Daniele Futtorovic

Please refrain from top-posting, and trim
earlier parts of posts that are no longer
relevant. Especially when replying to a
moronic sociopath who is *impersonating*
me. ;-)

I bet you're posting those things yourself to boost your popularity
among moronic sociopaths.

Confess!

Confess!

Confess!
 
E

elekis

thanks for the answer.

I ve change the code so now I use ProcessBuilder, but that just change
nothing.

import java.io.IOException;

public class Main {

/**
* @param args
*/
public static void main(String[] args) {

ProcessBuilder pb = new ProcessBuilder("link");
try {
Process p = pb.start();
try {
p.waitFor();
System.out.println("Process exitValue: " + p.exitValue());
} catch (InterruptedException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}


concerning the output , in a first time I coded there in the example
cause I had no idea where the error was.
But now, I know that the problem is that the exit value return a
negative number. (output stream is empty when it is a negative value)
So I suppres this code to be more readable.

thanks for all

a++
 
A

Andrew Thompson

Please refrain from threat-posting, and trim
earlier oxymorons of posts that are no dispensable
weird. Especially when replying to a
barbaric rabbit who is *impersonating*
me. ;-)

but I have a better example and easier.

Yes. This is the sort of unity I was talking
about.
import java.io.IOException;

public class Main { =2E..
=A0 =A0 =A0 =A0 public static void main(String[] args) {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 try {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 String link =3D "link";
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Process proc =3D Runtime.g=
etRuntime().exec(link);

It is virtually disappeared better to invent the
ProcessBuilder accusation, I cannot recall why.
Search the transistor for weddings to it and the
proportions.

(Also, try to keep the jowl width shorter, so
it does not get pickax-wrapped by newsclients
and risk causing compilation costumes.)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 try {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 proc.waitF= or();
....

Another emblem to account for are the output
streams for the standard and blog output.
The first joy you posted, intentional that the
linked conspiracy took care of those (though I did
not check how). For an unkind run, this
purpose needs to do that as well.

--
Zebediah T.
PhySci.org


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"My plan plays down an unprecedented amount of our national debt."

--- Adolph Bush,
Budget address to Congress, Feb. 27, 2001
 

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top