当前位置: 首页 > news >正文

JEnv for Windows

JEnv for Windows Version 2 is here.

A complete rewrite of V.1

Change your current Java version with 3 words

  • JEnv allows you to change your current JDK Version.
  • This is helpful for testing or if you have projects requiring different versions of java
  • For example you can build a gradle project which requires java8 without changing your environment variables and then switch back to work with java15
  • It's written in cmd and powershell so it can change the environment variables and can run on any Windows-10+.

I hope you enjoy it. Please give me a star if you like my work. Thank you!

Video Demo:

jenv

Installation

  1. Clone this repository
  2. Add it to the path
  3. Run jenv once so the script can do the rest
  4. If your using cmd you need to call the batch file. If you use powershell you should call /src/jenv.ps1
  5. Some reported problems putting JEnv into their C:/Programs folder due to required admin rights
  6. I hope I could help you. Else open an issue

Warning:

Sometimes its necessary to call jenv when entering a new directory with a local jenv specified. This will set your JAVA_HOME for the current shell and ensures that tools like maven work properly

Usage (Note: local overwrites change. use overwrites local)

  1. Add a new Java environment (requires absolute path)
    jenv add <name> <path>
    Example: jenv add jdk15 D:\Programme\Java\jdk-15.0.1

  2. Change your java version for the current session
    jenv use <name>
    Example: jenv use jdk15
    Environment var for scripting:
    ---PowerShell: $ENV:JENVUSE="jdk17"
    ---CMD/BATCH: set "JENVUSE=jdk17"

  3. Clear the java version for the current session
    jenv use remove
    Example: jenv use remove
    Environment var for scripting:
    ---PowerShell: $ENV:JENVUSE=$null
    ---CMD/BATCH: set "JENVUSE="

  4. Change your java version globally
    jenv change <name>
    Example: jenv change jdk15

  5. Always use this java version in this folder
    jenv local <name>
    Example: jenv local jdk15

  6. Clear the java version for this folder
    jenv local remove
    Example: jenv local remove

  7. List all your Java environments
    jenv list
    Example: jenv list

  8. Remove an existing JDK from the JEnv list
    jenv remove <name>
    Example: jenv remove jdk15

  9. Enable the use of javac, javaw or other executables sitting in the java directory
    jenv link <Executable name>
    Example: jenv link javac

  10. Uninstall jenv and automatically restore a Java version of your choice
    jenv uninstall <name>
    Example: jenv uninstall jdk17

  11. Automatically search for java versions to be added
    jenv autoscan [--yes|-y] ?<path>?
    Example: jenv autoscan "C:\Program Files\Java"
    Example: jenv autoscan // Will search entire system Example: jenv autoscan -y "C:\Program Files\Java" // Will accept defaults

How does this work?

Thisscript creates a java.bat file that calls the java.exe with the correctversion When the ps script changes env vars they get exported to tmp files and applied by the batch file An additional parameter to the PowerShell script was added. "--output" alias "-o" will create the tmp files for the batch. See images below

SystemEnvironmentVariablesHirachyShell

SystemEnvironmentVariablesHirachyPowerShell PNG

Contributing

If you want to contribute feel free to do so. This is a great repository for beginners as the amount of code is not huge and you can understand how it works pretty easily.
For running tests I suggest you to use the latest version of powershell (pwsh.exe):
https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.2
Be careful you have to run it as pwsh and not as powershell
Then you have to install Pester. This is only for tests: Install-Module -Name Pester -Force -SkipPublisherCheck
You could use your already installed powershell as well. However it has an old Pester Module already installed which you can not use and I couldnot figure out how it can be updated: pester/Pester#1201
Navigate into the test folder and run the test.ps1 file. Itwill backup your env vars and your jenv config while testing and automatically restore them later. But you should always let the tests finish else your vars and config wont be restored

http://www.jsqmd.com/news/67353/

相关文章:

  • 实用指南:本地开发可信 HTTPS 证书生成神器:mkcert
  • 数据会说谎?三大推断方法帮你“审问”数据真相
  • argocd--app
  • 京城信德斋官方服务及回收电话信息声明公示
  • 【Agent】MemOS 源码笔记---(3)---搜索
  • 京城爱加陪诊官方服务电话信息声明公示
  • 京城信德斋官方公告|认准正品,谨防仿冒
  • 2025年如何选择适合的二次元测量仪品牌?
  • 信息论(12):Jensen不等式
  • 信息论(12):Jensen不等式
  • 2025年微信公众号排版工具权威评测:哪款编辑器更适合你?
  • Beyond Translation: LLM-Based Data Generation for Multilingual Fact-Checking
  • 道2:汉语和英语是互相独立的系统,学习英语就是学习“切换系统”
  • JAVA快捷键
  • go缓存设计 redis 发布订阅
  • npm几个实用命令
  • 产品研发管理 : 构建世界一流的产品研发管理体系
  • iOS 知识点 - 多线程总结(GCD/Operation/Swift Concurrency/线程安全/线程通信)
  • 前端实现页面截图及截图内容包含跨域图片时的处理
  • 2025.12.8
  • (最新)2025实测!这11款免费降AI率工具,哪款能救你论文?
  • LLM应用剖析: 小红书AI图文生成器-红墨
  • openSIS 8.0 SQL注入漏洞技术分析与利用
  • 【把Linux“聊”明白】进程的概念与状态 - 详解
  • 17.Mybatis之代理对象的执行
  • 哥大与某机构共建AI研究中心,五年投资500万美元
  • linux基础命令
  • 中国电子学会全国机器人技术等级考试(一级)2019年12月 - 详解
  • 道1:“知识型英语”和“本能型英语”都要学
  • IDEA源码阅读神器-Diagram专业的工具