I have an existing jar file which I run. It is the Selenium RC server. I want to be able to change the JVM httpProxy.host/port/etc system values. On the one hand I can modify the source and add this feature in. Would take some time. Is there another possible way to do this? Like have my own JAR (which would set these JVM properties) invoke selenium-rc inside that very same JVM instance (that way it would be able to modify its JVM variable's values) ?
I know... I want to do this without having to possibly modify selenium-rc.
Zombies
2010-07-18 22:47:18
Have you tried this in your code? You do not need to modify Selenium RC.Given that your existing client code (that runs Selenium RC) runs in the same JVM, setting the system property will really work.
yclian
2010-07-19 00:48:05
@Esko Luontola: OH!? I didn't know the client also ran in the same JVM.... But that might interfere with the client, won't the client try to connect through the remote (and ofc very slower) proxy before (trying) to connect back to selenium-rc?
Zombies
2010-07-19 01:29:50
+4
A:
You can define system properties on the command line, using
-DpropertyName=propertyValue
So you could write
java -jar selenium-rc.jar -Dhttp.proxyHost=YourProxyHost -Dhttp.proxyPort=YourProxyPort
See Java - the java application launcher,
EDIT:
You can write a wrapper that is an application launcher. It's easily to emulate calling a main
method in a class using reflection. You then can also set system properties via System.setProperty
before launching the final application. For example,
public class AppWrapper
{
/* args[0] - class to launch */
public static void main(String[] args) throws Exception
{ // error checking omitted for brevity
Class app = Class.forName(args[0]);
Method main = app.getDeclaredMethod("main", new Class[] { (new String[1]).getClass()});
String[] appArgs = new String[args.length-1];
System.arraycopy(args, 1, appArgs, 0, appArgs.length);
System.setProperty("http.proxyHost", "someHost");
main.invoke(null, appArgs);
}
}
mdma
2010-07-18 22:52:11