Calling java from shellscript with parameters [duplicate] - java

This question already has answers here:
Propagate all arguments in a Bash shell script
(12 answers)
Closed 3 years ago.
From a shell script, I would like to call a shell script which calls a java program. The parameters to the java program are passed from the first shell script.
shellscript1 --> shellscript2 (set par1) --> Java par1
I have tried to source shellscript2 in shellscript1. Still couldnt pass parameters. I dont want to export the parameters and call shellscript2
Any ideas appreciated

Do not use shellscript 2 but add the param to shellscript 1. Using 2 shellscripts makes it complex.

Related

How to call python script form java class [duplicate]

This question already has answers here:
Calling Python in Java?
(12 answers)
Closed 8 years ago.
I have a java web app where i need to use a simple web crawler to read html from webpages. I could not find any simple solution for this in java. But got a very simple python script that solve my problem. Now how to call that python script (.py) from my java class and also get the returned value from the python script .Thanks in advance .
First check out Calling Python in Java?
Another approach might be to call the python interpreter from the command line with a Java Process. See Java Process with Input/Output Stream and Call python script within java code (runtime.exec)

How to execute shell script from Java applet [duplicate]

This question already has answers here:
executing shell scripts in java script or trigger scanner from browser
(2 answers)
Closed 9 years ago.
I want to access a document scanner on client's side so I have created a shell script to perform this action. Is there any way to execute it through a browser applet? Is there a way to make it work on Fedora 18 OS that will allow me to install a plugin like twain? This how I call my script currently:
String[] cmd = {"sh test.sh", "/Path/to my/resource file"};
Runtime.getRuntime().exec(cmd)
You can use Java Web Start or a signed applet.

Java Change File Working Directory [duplicate]

This question already has answers here:
Changing the current working directory in Java?
(14 answers)
Closed 9 years ago.
I'm writing some unit tests. I'm running the tests by invoking the classes directly (rather than invoking another program). The problem is that some of these classes use data defined by relative paths, so they require that the program is started in a specific directory. How can I change this in Java?
For instance, my unit test starts in C:/unittest, and the data I need is in C:/OtherProject. I don't want to modify the code of the other project if possible, is there something like this in java:
File.setWorkingDir("C:/OtherProject");
That way when something like
File file = new File("data/data.csv");
Will read C:/OtherProject/data/data.csv instead of C:/unittest/data/data.csv.
Updating my answer, since VolkerSeibt pointed out that it was incorrect. Good catch.
This is possible through System.setProperty. You can change the current working directory by changing the "user.dir" system property:
System.setProperty("user.dir", "/foo/bar");
See http://www.javacodex.com/Files/Set-The-Current-Working-Directory for further explanation.

how to specify username and password for jconsole from command line? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
JConsole command line credentials
Is there a way to specify username and password for jconsole from command line? I want to start jconsole completely from command line because the host name is too long (service:jmx:rmi://serveraddress:8010/jndi/rmi://serveraddress:8000/jmxrmi) and I can't remember them.
Thanks,
You need to write a bat file with all the parameters (or) command line like below. Something like this.
jconsole -J-Djavax.net.ssl.keyStore=value
-J-Djavax.net.ssl.keyStorePassword=value
-J-Djavax.net.ssl.trustStore=value
-J-Djavax.net.ssl.trustStorePassword=value
Note: This is example, actual parameters you need should be substituted instead of these.

Java Command Line? [duplicate]

This question already exists:
Closed 12 years ago.
Possible Duplicate:
Java REPL shell
Hey,
Is there any way to execute Java code (as you type) on a command line?
For instance, something like this
(command line)
java
import ARDrone;
ARDrone drone = new ARDrone(null, null, null);
drone.takeoff();
(so that you can enter lines of code in the command line)
Groovy can do that. It's possible with java syntax and groovy syntax.
You can try at Groovy web console. You have also groovy console and groovy shell.
You are looking for an interpreter.
Google tells me that BeanShell appears to be one, although I don't know Java and have never heard of BeanShell.

Categories