FelixSelter / JEnv-for-Windows

Change your current Java version with one line
Apache License 2.0
676 stars 87 forks source link

Discovery / Search Feature #32

Closed ebresie closed 2 years ago

ebresie commented 2 years ago

Not sure if this is needed in the jenv itself or just windows flavor but...

Presently, jenv requires to manually "add" each jdk path on the system.

It would be nice to have a jenv discover feature which would search the system (maybe can specify a specific path to reduce the search), to discover available JDKs present.

So if there is a collection of different java versions in a given folder, find and add each of the JDK folders. Maybe with each find could have an "autogenerated" id/label and/or path shown and ask if would like to add or not for use in an interactive mode.

May have to take care also to not add the same version multiple times so check if given one exists already from the list of know/previously added jdks.

ebresie commented 2 years ago

Also raised a similar issue in the jenv project. See https://github.com/jenv/jenv/issues/362

FelixSelter commented 2 years ago

That sounds like a great feature. Do you want to work on it?

FelixSelter commented 2 years ago

This is now implemented and will therefore be closed. View Readme for jenv autoscan

rcsilva83 commented 2 years ago

This jenv autoscan is great! Would it be possible to accept some kind of -y to autoaccept the suggested name, so there is no need of user intervention?

FelixSelter commented 2 years ago

Sure. This can be easily implemented. Out of curiousity, why would one not want to review the suggestions? Are you writing any script that uses JEnv?

Would you please open a new issue so this can be implemented. Also answer thefe if the -y flag is just for names or also to add the java version? Should they be separated i to two flags?

rcsilva83 commented 2 years ago

Out of curiousity, why would one not want to review the suggestions? Are you writing any script that uses JEnv?

Yes, we are trying to automate some things for our developers.

Would you please open a new issue so this can be implemented. Also answer thefe if the -y flag is just for names or also to add the java version? Should they be separated i to two flags?

Sure. I'll open now!

FelixSelter commented 2 years ago

In this case, it might be better to copy a jenv.config template into the config folder. I suppose your company has all its Java versions installed on C:/ProgramFiles/java/ or at some fixed path that won't change. Then you could create a jenv.config, add all the versions with custom names, and when a new user profile is created automatically copy the config file into %APPDATA%/JEnv

rcsilva83 commented 2 years ago

Yes, this may do the trick for now. But I have 2 files there: jenv.config and jenv.config.json. On the second one there is information about locals and global too. Is it enough to only add versions to the first one?

BTW, I just see the new jenv add command on the original jEnv project. It doesn't require a name anymore and autocreate some alias for the specified installation. See here.

FelixSelter commented 2 years ago

There should be one config file here: %APPDATA%/JEnv/jenv.config.json Every other file named jenv.config is most likely from an old version of jenv and can safely be deleted.

I thought of maybe a template name like `java%version% where %version% will be replaced by the java version. This would allow for more flexibility and could be expanded in the future. but let's discuss this in the new issue.

It would be exciting though if you would keep me up to date on how your company integrated jenv into the workflow. As I do not use windows anymore I often don't know what the problems are and what features are missing