-5

I want to know that is there a way to determine a output of any java program without any dedicated IDE? For an example, a program snippet may be like...

int i=3,n=0;
while (i<4)
{
   n++;
   i--;
}
System.out.println(n);
  • Is here someone to answer my question? – Captain Tiger Jun 20 '21 at 14:34
  • I want to determine a correct output – Captain Tiger Jun 20 '21 at 14:40
  • ...Like the one i added with the question... – Captain Tiger Jun 20 '21 at 14:41
  • There is no "correct output" in your question. I downvoted because [No research](http://idownvotedbecau.se/noresearch/) – Timothy Truckle Jun 20 '21 at 14:41
  • I also know i can write a java program without an IDE... i have a basic knowledge – Captain Tiger Jun 20 '21 at 14:42
  • It depends on your OS (shells, environment variables). Your question seems basic so forgive posters if they ask for missing basic info. Like what attempts have you made? – Alan Jun 20 '21 at 14:44
  • Will the program prints the value of n? – Captain Tiger Jun 20 '21 at 14:49
  • Related: [How to launch single-file programs in Java 11 (or later)?](https://stackoverflow.com/questions/51935636/how-to-launch-single-file-programs-in-java-11-or-later) – andrewJames Jun 20 '21 at 15:06
  • With a small fragment of code like the one in the question, can you step through it line-by-line in your head, and understand what each line is doing? If not, then you can research the specific statement/syntax which is causing a problem. If you want to confirm your understanding by executing the code in as simple a way as possible, then you now have several suggestions, here. (There are also online tools which can execute your Java code.) But learning to use an IDE will be a good investment (assuming you don't already use one). – andrewJames Jun 20 '21 at 15:21
  • Does this answer your question? [How to execute a java .class from the command line](https://stackoverflow.com/questions/1279542/how-to-execute-a-java-class-from-the-command-line) – Amal K Jun 20 '21 at 16:29

2 Answers2

0

If you got JDK9+ you can run your java code on prompt with no ide. try run jshell on prompt/cmd/powershell and test your code. if you need run a lot of line on jshell try /edit

Dilermando Lima
  • 1,004
  • 8
  • 21
0

If you use Java version 9 or higher, you can use the Java REPL (JShell) to try pieces of code. Install it on your computer, or use an online service (e.g. replit.com).

Or, use a text editor, and create a .java file, compile it and run it: https://docs.oracle.com/javase/tutorial/getStarted/cupojava/win32.html

Ruigerd
  • 16
  • 2