r/javahelp • • Aug 21 '20

Skipping javac

I haven't really used the command line java and javac in a while since I use Ant or some other build tool. When did they make it so you could run the following:

java MyApp.java 

Instead of having to do

javac MyApp.java java MyApp 

I just updated from JDK11 to 14, but I guess this also worked in JDK11, just never tried it I guess.

16 Upvotes

5 comments sorted by

5

u/8bagels Aug 21 '20

It should be noted that for a quick script this works but if you have other classes or dependencies you will still want to do a full compile and classpath declaration

1

u/SexyBlueTiger Aug 21 '20

Definitely. I just stumbled on it when I was trying out jpackage and realized I had typed java instead of javac and it just ran my program. I was surprised to say the least.

1

u/sinistergroupon Aug 21 '20

I know this is a thing but I really don’t understand why this is so groundbreaking to anyone. This only works for one file programs with no dependencies so it cannot be used for any real development. And any development is done in an IDE which does this for you. Who calls javac/java manually?