Why is the .java extension mandatory when using jbang init
?
#676
-
Last time I used
This works great and the file can be executed with:
(as indicated by the tool: Not having the I was wondering why the E.g create a file If there is a real use case for this file without any extension, at least it should be added when |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I assume you meant to ask "Why is the .java extension not mandatory?" ? it is not mandatory so you can use the script as if it was a shell script - some people get really caught up by files being named .py, .sh, .java, etc. when they can just be named what they do and then have the used language being a implementation detail.
when you do I'm not sure what you are seeing as an issue as it seems to me it works exactly how you ask ?
I think with jbang alias and catalogs we have quite a powerful mechanism to provide shorthand names. Adding one more here, especially for a physical named thing you already explicitly created using the short name "fooBar" feels "too much" imo. i.e. I don't see a compelling use case for it. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the quick reply. Sorry if my message was not clear enough. Let me simplify what I mean: When I run:
I expect the file |
Beta Was this translation helpful? Give feedback.
-
Gotcha - the current behaviour is intentional. See https://github.com/jbangdev/jbang#extension-lessnon-java-files-for-cli-plugins in short - if jbang forced |
Beta Was this translation helpful? Give feedback.
Gotcha - the current behaviour is intentional. See https://github.com/jbangdev/jbang#extension-lessnon-java-files-for-cli-plugins
in short - if jbang forced
jbang init kubectl-foobar
to bekubectl-foobar.java
you can't use jbang scripts to allowkubectl foobar
since it will be loooking forkubectl-foobar
file in thePATH
notkubectl-foobar.java