r/java • • Jul 04 '18

New Java 11 Feature: Launch Single-File Source-Code Programs

https://medium.com/@afinlay/new-java-11-feature-launch-single-file-source-code-programs-fadd698abf54
158 Upvotes

47 comments sorted by

View all comments

Show parent comments

22

u/zero_divide_1 Jul 04 '18

I'm hearing that the new hotness is to use

#!/usr/bin/env interpreter

In the event that the user has a different Java that they want to use or it's installed somewhere different. So this would be

#!/usr/bin/env java

But, like any approach, there are drawbacks.

5

u/CharlesGarfield Jul 04 '18

But what if the user wants to use a different "env"?

22

u/zero_divide_1 Jul 04 '18

Oh, I see you too are a Java developer... Abstractions all the way down.

21

u/CharlesGarfield Jul 04 '18

Really should be using an EnvFactory, anyways.

6

u/F3z345W6AY4FGowrGcHt Jul 05 '18

EnvFactoryImpl

6

u/HenrikWL Jul 05 '18

We all know what we really need is an EnvFactoryFacadeRepositoryImpl