-1

Is there any way to compile and run a java file without cmd? I want to compile and run java source files by clicking a button like in ides.

Can I do that?

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249

3 Answers3

1

there are many options.

  • use IDE
  • Use Build tools
  • batch file

for learners it is good to create a batch file(with .bat extension) or use IDE.

simply create a file with anyname.bat and write

javac YourPathToFile\yourClass.java
java YourPathToFile\yourClass
pause;

save it and double click on that file. (make sure your path variable is already set)

Sindhoo Oad
  • 1,194
  • 2
  • 13
  • 29
0

You can create the jar file and execute using javaw.exe -jar

Thanigai Arasu
  • 413
  • 3
  • 14
0

If you using Eclipse IDE then Eclipse is automatically compiling your code on the fly.

Or In Eclipse, You can un-check the build automatically in Project menu and then build by hand by type Ctrl + B, or clicking an icon the appears to the right of the printer icon.

Shiladittya Chakraborty
  • 4,270
  • 8
  • 45
  • 94