Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to know how I can convert a .bat file to a .exe file programmatically in Java, I'mm trying to make a Batch IDE.
Thanks!
Here is a snippet of code that I found online:
public static void main(String[] args) {
try {
Runtime.getRuntime().exec("c:\\executable.exe");
Runtime.getRuntime().exec("cmd /c c:\\batch_file.bat");
} catch (IOException e) {
}
}
More information on this topic can be found here.
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 2 years ago.
Improve this question
I want the "for" loop to keep executing even after the error occurs in Selenium java using negative test cases in an "if" "else"if-else statement. Some examples would really be helpful.
Use try Catch inside for loop.
for(int i=0;i<=10;i++){
try{
//your goes code here
}catch(Exception e){
System.out.println("Exception thrown "+e);
}
}
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 1 year ago.
Improve this question
I'm working on a java project and I want to attach a calculator from the operating system. But I haven't any idea to do that. If there any idea it would be a great help.
You can use
java.lang.Runtime.getRuntime().exec("[path]\calc.exe");
To open the calculator. But beware: The only way that you can communicate with applications you open this way is through the Process streams: in/out/err (assuming calc is set up to communicate as such)
in cmd you can type calc.exe and run it, to run calculator through the java use the java.lang.Runtime class to run commands:
try {
Runtime.getRuntime().exec("calc.exe");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
more details about Shell Commands in java read this...
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want a program for printing numbers in below format in java.
for(int i=0,r=1;i<h.length/2;) {
//System.out.println(h[i]);
for(int j=i;j<r;j++) {
System.out.print(h[j]);
}
System.out.println("");
r=r+2;
}
The expected output should be
1
24
356
System.out.println("1\n\n24\n\n356");
</sarcasm>
more information is needed (what is your exact problem? what do you want to achieve? input -> outcome)
what have you tried and where exactly are you stuck.
Edit your question and i edit my answer ;)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
This java code has output a html code, to generate a final result I need copy/paste and save filex.html.
How can I write this code to generate a report.html file in C:/ ?
System.out.println(html);
This should do the trick:
PrintWriter out = new PrintWriter("C:\report.html");
out.print(html);
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
How would i play a specific song in iTunes through java?
I assume I need to somehow connect to iTunes and use the play function with a certain parameter....Can anyone point me in the right direction to learning how to do this?
According to that answer, there is no API. There is only an SDK (via COM) for Windows.
In Mac OS, iTunes is controlled via AppleScript(example).
Ik it's too late, but u can use apple script editor. for instance,
Runtime runtime = Runtime.getRuntime();
String[] args = {"osascript" , "-e" , "tell application \"iTunes\" to play"};
try{
Process process = runtime.exec(args);
}catch (Exception ex) {
}
this will play a song in itunes