当前位置: 首页 > 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.gsyq.cn/news/77886.html

相关文章:

  • 京城信德斋官方公告|认准正品,谨防仿冒
  • 2025年如何选择适合的二次元测量仪品牌?
  • go缓存设计 redis 发布订阅
  • npm几个实用命令
  • 产品研发管理 : 构建世界一流的产品研发管理体系
  • 2025.12.8
  • (最新)2025实测!这11款免费降AI率工具,哪款能救你论文?
  • LLM应用剖析: 小红书AI图文生成器-红墨
  • 17.Mybatis之代理对象的执行
  • 哥大与某机构共建AI研究中心,五年投资500万美元
  • 中国电子学会全国机器人技术等级考试(一级)2019年12月 - 详解
  • IDEA源码阅读神器-Diagram专业的工具
  • 读书笔记 XILINX ug1137-Zynq UltraScale+ MPSoC Software Developer Guide 软件开发者指南 Chapter7
  • 2025 年优质服装批发市场推荐:精准适配需求,解锁高效采批新体验
  • thinkphp6 request /i /s等转换
  • An Explainable KG-RAG-Based Approach to Evidence-Based Fake News Detection Using LLMs
  • 10 种低情商行为
  • 男士洗面奶哪个牌子最好?露卡菲娅山茶花洗面奶,排行榜单热销款揭秘!
  • flex布局精进: align-items: stretch;属性
  • v-if
  • langchain4j 学习系列(6)-结构化输出(参数提取)
  • if 的虚拟语气和省略形式
  • 【论术】项目复盘总结-响应式界面
  • 高级语程序设计第八次作业
  • cs61a-36链表的练习
  • 数据库操控与数据管理——Rust 与 SQLite 的集成
  • 20232315 2025-2026-1 《网络与系统攻防技术》实验八实验报告
  • 3分钟搞定,CI/CD工具Arbess安装和配置 - 详解
  • Ring智能可视门铃调试代码漏洞致远程代码执行
  • 完美的盆栽配土