Giter Site home page Giter Site logo

jenv-for-windows's Introduction

index

An eager student from Germany that always wants to learn something new.

  • 🔭 I’m currently working on JEnv-for-Windows

  • 📝 I regularly write articles on [Probably coming soon](Probably coming soon)

  • 📫 How to reach me [email protected]

  • You are the Visitor Count Person watching my profile

Connect with me:

felixselter

Languages and Tools:

bash blender bootstrap css3 docker express figma git html5 java javascript jekyll jest linux mongodb nginx nodejs photoshop postman python react redis selenium typescript unity webpack

Support:

FelixSelter

jenv-for-windows's People

Contributors

felixselter avatar h4iku avatar hconstantinsdl avatar quaeast avatar rcsilva83 avatar serg06 avatar treaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jenv-for-windows's Issues

Cannot add Java in folder with space

My folder has a space in the name. Jenv is not finding the java file.

jenv add C:\Program Files\Java\jre1.8.0_311
The specified path is not a valid JAVA_HOME. File not found:
Files\Java\jre1.8.0_311\bin\java.exe

I also tried the short name and that also fails.

"jenv list" not display jdk currently used after "jenv local" and then "jenv use" in a directory

If I specify locally a jdk (i.e. jdk11) in a directory using "jenv local" command and then specify another jdk (i.e. jdk17) for the current session using "jenv use" command, then when I display the jenv environment using "jenv list" command, the output cannot tell me correctly which version of java I'm now using.

[somebody@HOME-PC datahub]# jenv local jdk11
Your replaced your java version for D:\idea_workspace\datahub jdk11
[somebody@HOME-PC datahub]# java --version
openjdk 11.0.20 2023-07-18
OpenJDK Runtime Environment Temurin-11.0.20+8 (build 11.0.20+8)
OpenJDK 64-Bit Server VM Temurin-11.0.20+8 (build 11.0.20+8, mixed mode)
[somebody@HOME-PC datahub]# jenv list
All avaible versions of java

name  path
----  ----
jdk8  D:\ProgramFiles\java\jdk8u382-b05
jdk11 D:\ProgramFiles\java\jdk-11.0.20+8
jdk17 D:\ProgramFiles\java\jdk-17.0.7+7


All locally specified versions

path                      name
----                      ----
D:\idea_workspace\datahub jdk11


[somebody@HOME-PC datahub]# jenv use jdk17
JEnv changed for the current shell session. Careful this overwrites "jenv local"
[somebody@HOME-PC datahub]# jenv list
All avaible versions of java

name  path
----  ----
jdk8  D:\ProgramFiles\java\jdk8u382-b05
jdk11 D:\ProgramFiles\java\jdk-11.0.20+8
jdk17 D:\ProgramFiles\java\jdk-17.0.7+7


All locally specified versions

path                      name
----                      ----
D:\idea_workspace\datahub jdk11

JEnv is changing your environment variables. This process could take longer but it happens only when a jenv executable is found in your path

Hi,

I like the idea of this tool, like pyenv or nvm. I installed it and am testing it right now.
But somehow I can't get rid of

JEnv is changing your environment variables. This process could take longer but it happens only when a jenv executable is found in your path

The tools seems to work, but everytime I'm using jenv it prints out the warning/text.
Why is that? Do I have something to do to get rid of?
The manual especially says I should put JRE on the Path.

Best regards,
Dieter

Auto update

I think it would be a good idea if the script would check this repo if there are any changes. It could then prompt a question if it should download these changes. Probably a way to disable auto-update checks.

Please, make releases

I'm creating a scoop manifest but it's better when there are releases to download the artifacts.

Every invocation results in "JEnv is changing your environmental variables"

I just installed jenv. Every time I do jenv list, I get this output:

C:\Users\Name>jenv list
JEnv is changing your environment variables. This process could take longer but it happens only when a java executable is found in your path
All avaible versions of java

All locally specified versions

And when I trigger it again, I get this output:

C:\Users\Name>jenv list
'where' is not recognized as an internal or external command,
operable program or batch file.
'where' is not recognized as an internal or external command,
operable program or batch file.
Neither pwsh.exe nor powershell.exe was found in your path.
Please install powershell it is required

Forcing me to restart my terminal.

When I restart it, the whole process repeats itself.

Option to download and install java versions

Would be super convenient if jenv could not only switch Java versions, but also had the ability to go ahead and install the configured version. It's also desirable the ability do configure a "dist URL" to be able to download from a local mirror when the user is behind a corporate firewall.

List registered JDKs

Please add a command line option, which list the location of all registered JDKs.

Commands other than java do not work

Hi, thanks for the great tool.

I upgraded my installation by pulling from the repository and adding my JDKs back. Now commands like javac or jshell don't work.

❯ java -version
openjdk version "11.0.14.1" 2022-02-08
OpenJDK Runtime Environment Temurin-11.0.14.1+1 (build 11.0.14.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.14.1+1 (build 11.0.14.1+1, mixed mode)
❯ javac
javac: The term 'javac' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
❯ jshell
jshell: The term 'jshell' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Since the java command is processed through java.bat, I guess every command needs its own bat file now?

The file jenv.ps1 is not digitally signed

File C:\Programs\JEnv-for-Windows\jenv.ps1 cannot be loaded. The file C:\Programs\JEnv-for-Windows\jenv.ps1 is not
digitally signed. You cannot run this script on the current system. For more information about running scripts and
setting execution policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess

Autoaccept defaults on "jenv autoscan"

Add a parameter like -y to autoaccept the java versions and suggested names, so there is no user prompt and this can be used on scripts to automate the developer environment configuration.

Error when removing any Java version

Steps to reproduce:

  • jenv add openjdk17 <path to openjdk17>
  • jenv remove openjdk17

Error:

Rename-Item: <path to JEnv installation>\jenv.ps1:157
Line |
 157 |      Rename-Item -path $jenvConfigTmp -NewName $jenvConfig
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot find path 'C:\Users\<me>\AppData\Roaming\JEnv\jenv.config.tmp' because it does not exist.

Removed JEnv openjdk17 successfully

Obs.:
The error only occurs when the item being removed is the only one in the config.

Discovery / Search Feature

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.

Extra output on first run

On the first execution, when the jenv.config file doesn't exist, some extra text is printed to console:

jenv list                                                                             0ms

    Directory: C:\Users\<me>\AppData\Roaming

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          17/04/2012    01:33                JEnv
__JEnvs__

I think it's missing a | Out-Null here.

Environment variable backup

I believe adding a backup feature would be a good idea!

The situation is like this: I have personally implemented a similar feature, but due to my limited skills, it caused all of my system's PATH environment variables to be lost. This resulted in a significant loss of time and effort for me, so I can deeply relate to this issue.

As for the trigger for backups, it could be whenever there is a change in the variables or scheduled backups. The backup methods can include full backups, incremental backups, or differential backups. However, in the case of Java environment variables, I think a full backup mode would suffice since it wouldn't occupy too much space.

The above is just a small suggestion from my side. I hope to receive a response regarding this matter.

Error when jEnv is on a Path with spaces

I unzipped jEnv in a path with spaces (eg. "D:\path with spaces\jenv") but I get the following error when I run it:

Processing -File 'D:\path' failed because the file does not have a '.ps1' extension. Specify a valid Windows PowerShell script file name, and then try again.

There is no way to show the current global version

option 1: add to jenv list
option 2: rename jenv change(can still be an alias for backward compatibility) to jenv global. To set the global version jenv global XXX. to check the global version jenv global.

Non destructive PATH configuration

Instead of removing all java's from the PATH, I think it would be better only to ensure jenv is on the beginning of the list. This way, the user don't lose information and it makes it possible to remove jenv and return to the previous state.

Error when powershell.exe is not in the PATH

I don't have C:\WINDOWS\System32\WindowsPowerShell\v1.0\ in my PATH because I use the portable PowerShell, which is installed as C:\Program Files\PowerShell\7\pwsh.exe. It could be possible to check if it exists and use it before trying the windows build-in?

jenv change openjdk17
'Powershell.exe' is not recognized as an internal or external command,
operable program or batch file.

Jenv change throws error: setx is not recognized as an internal or external command

Jenv change seems broken. Or maybe I'm not reading the docs wrongly.
I've tried running the script from cmd and powershell with the same result

C:\Users\hconstantin\dev>jenv list
jdk11|"C:\Program Files\Java\jdk-11.0.10"
jdk8|"C:\Program Files\Java\jdk1.8.0_211"

C:\Users\hconstantin\dev>jenv change jdk11
Latest version installed is 16.9.31229.75
Located msbuild in C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\msbuild.exe
'setx' is not recognized as an internal or external command,
operable program or batch file.
Changed to jdk11

C:\Users\hconstantin\dev>java -version
'java' is not recognized as an internal or external command,
operable program or batch file.

Success message when removing invalid jdk name

When we execute jenv remove invalid, where invalid is an invalid jdk name, the command outputs the following message: Your JEnv was removed successfully. I think it should warn the user the given name is invalid.

Support jenv version <...> command and .java-version for Windows

Using jenv via brew install on macos for a while :)
Switching on MS Windows, Jenv-for-Windows is a really cool alternative, thanks for that !

A missing and very helpful option is the fact so support :
jenv version <...>

that will create a file .java-version locally where you are (for you current project as instance)
and next java -version command will use per defaut the jenv java version entry defined in the local .java-version

Is it a scheduled feature ?

Can't add a java version

Getting this error when trying to add a jdk:

C:\WINDOWS\system32>jenv add jdk15 C:\Program Files\Java\jdk-15
JEnv is changing your environment variables. This process could take longer but it happens only when a jenv executable is found in your path
Invoke-Add : A positional parameter cannot be found that accepts argument 'Files\Java\jdk-15'.
At C:\Users\pmcke\work\jenv\JEnv-for-Windows\src\jenv.ps1:153 char:15
+         add { Invoke-Add $config $help @arguments }
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-Add], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Invoke-Add

How to uninstall jenv

I installed it because I want to control the Java version, but there is a problem with my computer, so I want to delete jenv. How can I delete jenv and restore my java?

Use `.java-version` file for local version

To make the tool better interoperable between the windows version and the Linux/Mac version it would be great if the .java-version file would be used to determine what java version to use locally.

This would greatly help when using this in teams with developers on different operating systems, but all using JEnv.

Jenv use breaks PATH

I'm attaching the output of a couple of commands.
Let me know if you need more info.

C:\Users\hconstantin>java -version
java version "1.8.0_301"
Java(TM) SE Runtime Environment (build 1.8.0_301-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.301-b09, mixed mode)

C:\Users\hconstantin>cd dev

C:\Users\hconstantin\dev>jenv.bat use jdk11
Changed to jdk11

C:\Users\hconstantin\dev>java -version
'java' is not recognized as an internal or external command,
operable program or batch file.

The default javac version is used when the version is changed:bug

Brief description of bug

Self-Diagnosis

  • [√] I have reviewed the documentation.
  • I have reviewed the Wiki.
  • [√] I have tried to use the latest version.
  • I have searched the issues for an answer to my question.
  • I have searched the web for an answer to my question.

Environment(for bug reports)

  • [√] Operating System:Windows11
  • IDE version:
  • Plugin version:

My configuration/Related code

Steps to Reproduce the Issue

Current Result (Include screenshots where appropriate.)

Expected Result

A command to delete an entry from the jenv.config

jenv delete

Should be pretty self-explaining.
This is a simple task.
The project is very small too so it should be easy for beginners to contribute.
If you have any questions just ask.

I'm looking forward to your contribution

use command doesn't work on PowerShell

jenv use command using jenv.bat doesn't change the java version for the current session on PowerShell. Using jenv.ps1 works alright.

This is PowerShell 7.2.2 using jenv.bat:

❯ jenv list
All avaible versions of java

name  path
----  ----
jdk8  C:\Program Files\Java\jdk-8.0.322.6-hotspot
jdk11 C:\Program Files\Java\jdk-11.0.14.101-hotspot
jdk17 C:\Program Files\Java\jdk-17.0.2.8-hotspot

All locally specified versions

❯ java -version
openjdk version "11.0.14.1" 2022-02-08
OpenJDK Runtime Environment Temurin-11.0.14.1+1 (build 11.0.14.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.14.1+1 (build 11.0.14.1+1, mixed mode)

❯ jenv use jdk17
JEnv changed for the current shell session. Careful this overwrites jenv local

❯ java -version
openjdk version "11.0.14.1" 2022-02-08
OpenJDK Runtime Environment Temurin-11.0.14.1+1 (build 11.0.14.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.14.1+1 (build 11.0.14.1+1, mixed mode)

On cmd, however, it changes the java version but then jenv use remove doesn't revert it:

>java -version
openjdk version "11.0.14.1" 2022-02-08
OpenJDK Runtime Environment Temurin-11.0.14.1+1 (build 11.0.14.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.14.1+1 (build 11.0.14.1+1, mixed mode)

>jenv use jdk17
JEnv changed for the current shell session. Careful this overwrites jenv local

>java -version
openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment Temurin-17.0.2+8 (build 17.0.2+8)
OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode, sharing)

>jenv use remove
Your session JEnv was unset

>java -version
openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment Temurin-17.0.2+8 (build 17.0.2+8)
OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode, sharing)

JDKs with a space in the path do not work.

Tried to add jdk path that has a space in it. The list operation doesn't show the full path.
Example:
Run this:
jenv.bat add jdk8 "C:\Program Files\AdoptOpenJDK\jdk-8.0.292.10-hotspot"
Then this:
jenv.bat list
Output is this:
jdk8|"C:\Program

output should be:
jdk8|"C:\Program Files\AdoptOpenJDK\jdk-8.0.292.10-hotspot"

Conflicts with other batch file executions on windows

I was able to change the versions successfully using this tool but could not run any other batch file on windows until Jenv uninstall was executed and removed completely. Went crazy over this to try and search the source of the issue.

After uninstalling I can execute my applications batch files but Jenv is uninstalled from the system. Don't want to repeat the procedure of cloning and performing the steps again. Tool is nice, if someone could guide me if I did something wrong or if this is a bug and needs a fix?

Thanks!

Jenv.ps1 use not working

in the same powershell session I'm dong the following

PS C:\Users\hconstantin> java -version
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
PS C:\Users\hconstantin> cd .\dev\
PS C:\Users\hconstantin\dev> .\jenv.ps1 use jdk11
Removed C:\Program Files\Java\jdk1.8.0_211\bin\ from path
Added C:\Program Files\Java\jdk-11.0.10\bin to the path
PS C:\Users\hconstantin\dev> java -version
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
PS C:\Users\hconstantin\dev>

I would expect that after .\jenv.ps1 use jdk11, the reported java version would be 11.
Note that I already tested jenv change jdk11 and that works as expected

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.