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);
}
}
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 1 year ago.
Improve this question
I'm very new to Java and I was wondering why my code wasn't running.
Is there anything I need to do or I have missed out, every time I click run the bar at the bottom is just infinitely saying "running...".
Your code is asking for a user input before logging anything, that's probably why you think it's not running.
Try to print something before like this:
System.out.println("Enter a number:");
int i = scanner.nextInt();
System.out.println("You chose " + i);
(Pseudo code)
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 am fairly new to Java programming and have been using a for loop in my program. I noticed whenever my program asks for user input, that whenever I press the enter key that is used as the next key for the second iteration of the loop. Is there a way to make this not occur?
Use while loop instead:
while(true){
String input = JOptionPane.showInputDialog(null, "Please enter something.");//take inputs while have not encountered STOP
if(input.equals("STOP")){
System.exit(0);
}
}
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 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.
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 ;)