Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I’m new to python scripting and I need to install Java using python script . please suggest a method to do this.
Thanks all.
If i am not wrong you are looking for silent installation of Java. Here is a link that explains the same:
Silent installation of Java
Next you would want to run this command using python. For this you can use subprocess in python. Below is a link explaining it:
Using subprocess in Python
You want to display error stream too, so use the subprocess.Popen as:
process = subprocess.Popen(['command plus args as in above link'],stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = process.communicate()
out contains the output of the above command and err contains the error stream.
I would suggest you to install java from command line first, and then use this command in python script.
To install mySql or even tcl, follow similar steps,
1. Find how to install using command line
2. Execute the same command using python
Also, there may already be existing packages to do your job, if so you can use them.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 months ago.
Improve this question
I have found a Java application repository on GitHub which provides the application in JAR format and in the native binary format for different operating systems such as MacOS, Windows, Linux.
I am able to execute the JAR file using the java -jar command but I would like to run the native binary file so users can execute it without installing the Java in their system.
Can someone please inform me how can I run the binary file on Macos? I tried to search and found the command chmod +x name-of-binary but this command does not do anything.
I am really new to this and do not have much idea about this so any suggestion would be really helpful.
The most simple way would be to either open a terminal and manually running the binary, like so:
./<name-of-file>
This would only work if you are running the file in a user who has execution privileges on that file. if you run into trouble with priviliges, that's where I would use chmod.
If you need any more specific help, I would recommend posting the link to that GitHub repo for us to look at, and telling us what is it that it should do.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I've searched for similar questions, but despite there where a lot with a similar title all have asked something different.
In my case I want that my java program interact with the terminal (Windows) by writing command and reading the response.
I've found the class ProcessBuilder, but does not seem that do what I want
What I' m searching for is something so:
start the cmd at some given position (like C:\Users\federico)
issue a command (dir or cd desktop); this should not open a command prompt window
read any output that command may result in
and so on, up to the user's exit from the program.
I suspect you simply don't know the English terms for this: what you're looking for is a way to execute commands in the OS, which is called "exec" in every programming language I know of, including Java: https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#exec(java.lang.String)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I'm trying to compile my java code using a bash script. I need to pass in arguments too, which I'm getting from another file in the same directory. My script looks like:
#!/usr/bin/env bash
MYID="$(cat $(pwd)/my.id)"
eval javac src/main/java/foo/bar.java "$MYID"
but it thinks of my argument as another java file for compilation and gives me the error:
Class names, 'abc123', are only accepted if annotation processing is explicitly requested
P.S. abc123 is the only id in the my.id file I need to pass.
Please help me make this work, I have been looking for solutions the whole day. :(
edit: This was a stupid question.
I just realized I was passing in arguments at the wrong place. I figured it out. thankyou!
You are going about this the wrong way. The javac command compiles programs. That is it. It doesn't generate source code.
Based on your comments it sounds like you should be doing something like this:
javac foo/Bar.java
java foo.Bar $(cat my.id) > foo/Baz.java
javac foo/Baz.java
This assumes that foo.Bar is some kind of generator program that knows how to generate java source code.
In reality, I expect that what you are really trying to do is some kind of source-code template expansion. There are simpler and / or more flexible ways to do that that writing a bespoke Java program to do it. (For example, use the "m4" utility.)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I was thinking of passing the result from Java run from command line into a command line variable. But after searching much for it, I only came across Runtime class which just runs the command.
Therefore, my question, is there anything I can do to get Java result into command line.
Platform of course is Windows.
There are only 2 ways any program (Java or otherwise) can send results back to the "command line":
1) exit code
2) capture the strings output by the program.
#1 can be done in Java using System.exit (or see a couple more options here).
#2 is done by the shell. In Unix, you typically use backticks or $():
OUTPUT=`java app.class`
In Windows Powershell, do something like
$result = & java app.class 2>&1 | Out-String
Possible duplicate of
how-do-i-get-the-result-of-a-command-in-a-variable-in-windows
FOR /F "delims=" %i IN ('java Main') DO set today=%i
Also allows today variable to be set.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am writing a Java code for Linux RHEL 5 machine. The requirement is that while sitting at machine A, I should be able to edit some files in a remote machine B. Both machine A & B are RHEL. Now the following possibilities are there. Can anyone please suggest which is better or if any other way is there:
Write a shell script to do this. Execute the shell script from A such that changes happen in B
Write a java code on A, that is able to login to B and edit files in B.
Write a java file editing utility (pattern-matching thing). Push this util on B through another java code. Execute the file edit util in B. Somehow the trigger for executing the util in B should also be given by A
Thanks
Eclipse Remote System Explorer lets you do just that: http://www.eclipse.org/tm/
You can also use java library to do that :
http://www.jcraft.com/jsch/
Check out the examples link.
It depends on your needs but I think it is easier and faster to do that with bash scripts and some linux tools like nc, telnet or ssh for instance.
With ssh is as simple as:
ssh user#remote mkdir /tmp/new_directory
I hope it helps...