{"id":13840019,"url":"https://github.com/chroblert/JC-jEnv","last_synced_at":"2025-07-11T07:31:52.111Z","repository":{"id":44522382,"uuid":"331153726","full_name":"chroblert/JC-jEnv","owner":"chroblert","description":"windows java environ manage","archived":false,"fork":false,"pushed_at":"2023-07-08T01:34:56.000Z","size":149,"stargazers_count":139,"open_issues_count":5,"forks_count":33,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-05T17:24:35.425Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Batchfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chroblert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-01-20T01:06:30.000Z","updated_at":"2024-08-02T06:36:55.000Z","dependencies_parsed_at":"2024-04-24T08:59:40.971Z","dependency_job_id":"10aa4225-4455-444a-b76d-9cfa01320cf3","html_url":"https://github.com/chroblert/JC-jEnv","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chroblert%2FJC-jEnv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chroblert%2FJC-jEnv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chroblert%2FJC-jEnv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chroblert%2FJC-jEnv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chroblert","download_url":"https://codeload.github.com/chroblert/JC-jEnv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225705140,"owners_count":17511230,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T17:00:40.599Z","updated_at":"2024-11-21T09:30:44.871Z","avatar_url":"https://github.com/chroblert.png","language":"Batchfile","funding_links":[],"categories":["Java环境管理","Batchfile"],"sub_categories":[],"readme":"# JC-jEnv\n\n\u003e Author: JC0o0l,Jerrybird\n\u003e \n\u003e GitHub: https://github.com/chroblert/JC-jEnv.git\n\u003e \n\u003e WeChat: JC_SecNotes(Zer0ne安全研究)\n\n## 0x00 用途\nJava版本切换工具,可以很方便的在java的多个版本之间切换。可以设置只在当前的终端中生效还是在全局都生效。\n\n## 0x01 原理：\n\n- 通过reg,set,setx等命令修改或刷新JAVA_HOME,PATH,`\u003calias\u003e`等环境变量以及注册表。\n\n- 将添加的`\u003calias\u003e`保存到用户环境变量JC_jEnv中\n\n- 通过call来达到多重嵌套的效果\n\n- 通过doskey来设置命令别名\n\n## 0x02 效果：\n\n`jenv -h`\n\n![1611209361297.png](img/1611209361297.png)\n\n`jenv local java9`\n\n![1611210131816.png](img/1611210131816.png)\n\n`jenv version`\n\n![1611210177545.png](img/1611210177545.png)\n\n`jenv del java9`\n\n![1611210266710.png](img/1611210266710.png)\n\n`jenv add d:\\11-java\\jdk-9.0.4 java9`\n\n![1611210250119.png](img/1611210250119.png)\n\n\n\n\n## 0x03 参数说明：\n\n`jenv [options]`\n\noptions如下\n- version \n  - 显示当前设置的所有的java版本\n- local `\u003calias\u003e` \n   - 设置java版本，只在当前shell下起作用\n- global `\u003calias\u003e`\n   - 设置java版本，在全局下都起作用\n- add \u003c目录\u003e `\u003calias\u003e`\n   - 添加一个版本的java。\n   - 如：`jenv add d:\\java\\jdk-9.0.4 java9`\n- del `\u003calias\u003e`   \n   - 删除一个版本的java\n   - 如：`jenv del java9`\n\n## 0x04 使用说明：\n\n1. 将该bat脚本添加到PATH系统环境变量中\n\n    这样使用的时候，可以直接输入`jenv`\n2. 用户环境变量PATH中使用%JAVA_HOME%\\bin\n    \n    path环境变量中不能有具体的java路径，要使用%JAVA_HOME%\\bin的方式,无论系统环境变量还是用户环境变量\n\n3. 删除系统环境变量中的JAVA_HOME\n   因为生成path环境变量的时候，系统变量中的path\u003e用户环境变量中的path。而要修改系统环境变量，需要管理员权限，所以该程序只修改了用户环境变量。\n\n注：\n\u003e - 系统环境变量中PATH值中的路径下不能有java.exe。如：C:\\windows\\system32路径下有8版本的java.exe，则全局无法生效，即：即使jenv global java13,但每次新创建的cmd下运行的java都是C:\\windows\\system32路径下的那个。\n\u003e - 该脚本使用用户环境变量，因而系统环境变量中不能有JAVA_HOME变量\n\n## 0x05 测试环境\n\n|序号|系统|版本|是否支持|\n|---|-|--|--------|\n|1|Windows 10|专业版|支持|\n|2|  |  |  |\n|3|  |  |  |\n|4|  |  |  |\n\n\n##  参考资料：\n\n参考资料：[windows系统一键配置修改环境变量](https://www.jianshu.com/p/7d90042f644f)\n\n参考资料：[Windows设置cmd别名](https://blog.csdn.net/YiRanZhiLiPoSui/article/details/83116819)\n\n参考资料：[setx设置永久环境变量](https://blog.csdn.net/fm0517/article/details/52450940)\n\n参考资料：[刷新环境变量](https://github.com/chocolatey/choco/blob/master/src/chocolatey.resources/redirects/RefreshEnv.cmd)\n\n参考资料：[batch之变量延迟](https://www.cnblogs.com/ini_always/archive/2012/02/16/2355031.html)\n\n参考资料：[was unexpect at this time](https://stackoom.com/question/2pffV/%E8%9D%99%E8%9D%A0-Set%E5%91%BD%E4%BB%A4%E5%9C%A8%E6%8B%AC%E5%8F%B7%E5%86%85%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8)\n\n参考资料：[批处理变量多重嵌套](https://www.cnblogs.com/xxcanghai/p/4584042.html)\n\n参考资料：[环境变量中特殊字符()的问题](https://qastack.cn/superuser/119610/spaces-and-parenthesis-in-windows-path-variable-screws-up-batch-files)\n\n参考资料：[setx1024个字符限制的解决方法](https://qastack.cn/superuser/387619/overcoming-the-1024-character-limit-with-setx)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchroblert%2FJC-jEnv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchroblert%2FJC-jEnv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchroblert%2FJC-jEnv/lists"}