<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Han Li</title>
    <description>The latest articles on DEV Community by Han Li (@aooohan).</description>
    <link>https://dev.to/aooohan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1262819%2F77070a60-e31d-4a8e-88e0-38ad84351e36.jpeg</url>
      <title>DEV Community: Han Li</title>
      <link>https://dev.to/aooohan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aooohan"/>
    <language>en</language>
    <item>
      <title>Managing JDKs on native Windows (not WSL)</title>
      <dc:creator>Han Li</dc:creator>
      <pubDate>Mon, 01 Apr 2024 09:18:15 +0000</pubDate>
      <link>https://dev.to/aooohan/managing-jdks-on-native-windows-not-wsl-eb4</link>
      <guid>https://dev.to/aooohan/managing-jdks-on-native-windows-not-wsl-eb4</guid>
      <description>&lt;h1&gt;
  
  
  Overview
&lt;/h1&gt;

&lt;p&gt;We are very familiar with &lt;code&gt;sdkman&lt;/code&gt; or &lt;code&gt;asdf&lt;/code&gt;, they are great for unix-like, but for &lt;strong&gt;Windows&lt;/strong&gt; they depend on &lt;strong&gt;WSL&lt;/strong&gt;. This is unbearable. So through &lt;a href="https://github.com/version-fox/vfox"&gt;vfox&lt;/a&gt; implementation of a plugin similar to &lt;code&gt;sdkman&lt;/code&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  What Is vfox!?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;cross-platform support (Windows, Linux, macOS)&lt;/li&gt;
&lt;li&gt;single CLI for multiple languages&lt;/li&gt;
&lt;li&gt;support Global、Project、Session scopes when switching versions&lt;/li&gt;
&lt;li&gt;simple plugin system to add support for your language of choice&lt;/li&gt;
&lt;li&gt;automatically switches runtime versions as you traverse your project 
&amp;amp; more.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  How manage JDK on native Windows?
&lt;/h1&gt;

&lt;h4&gt;
  
  
  1. Choose an installation that works for you.
&lt;/h4&gt;

&lt;h4&gt;
  
  
  2. ⚠️ Hook vfox into your shell ⚠️
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Clink is on the way. see &lt;a href="https://github.com/version-fox/vfox/issues/129"&gt;issue-129&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# For PowerShell:&lt;/span&gt;
&lt;span class="c"&gt;# 1. Open PowerShell Profile:&lt;/span&gt;
New-Item &lt;span class="nt"&gt;-Type&lt;/span&gt; File &lt;span class="nt"&gt;-Path&lt;/span&gt; &lt;span class="nv"&gt;$PROFILE&lt;/span&gt; &lt;span class="c"&gt;# Just ignore the 'file already exists' error.&lt;/span&gt;
Invoke-Item &lt;span class="nv"&gt;$PROFILE&lt;/span&gt;
&lt;span class="c"&gt;# 2. Add the following line to the end of your $PROFILE and save:&lt;/span&gt;
Invoke-Expression &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;vfox activate pwsh&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Remember to restart your shell to apply the changes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  3. Add java plugin
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;vfox add java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  4. Install some runtimes
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;vfox &lt;span class="nb"&gt;install &lt;/span&gt;java@22-graal
&lt;span class="nv"&gt;$ &lt;/span&gt;vfox &lt;span class="nb"&gt;install &lt;/span&gt;java@17.0.10+7-zulu
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Maybe you want to view all available version?&lt;/p&gt;

&lt;p&gt;You can use &lt;code&gt;vfox search java&lt;/code&gt; to view it. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;vfox search java graal&lt;/code&gt; -&amp;gt; view all version for graalvm&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;vfox search java zulu&lt;/code&gt; -&amp;gt; view all version for zulu&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;All short names are same as SDKMAN!&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  5. Switch runtime
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;vfox use java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Demo
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EGpODBhs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://i.imgur.com/NGdmfLW.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EGpODBhs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://i.imgur.com/NGdmfLW.gif" alt="Image description" width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We no longer need to rely on WSL!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Plugin Repo: &lt;a href="https://github.com/version-fox/vfox-java"&gt;https://github.com/version-fox/vfox-java&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>tooling</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>How to manage multiple versions of Golang flexibly and elegantly?</title>
      <dc:creator>Han Li</dc:creator>
      <pubDate>Mon, 22 Jan 2024 08:17:53 +0000</pubDate>
      <link>https://dev.to/aooohan/how-to-manage-multiple-versions-of-golang-flexibly-and-elegantly-2il</link>
      <guid>https://dev.to/aooohan/how-to-manage-multiple-versions-of-golang-flexibly-and-elegantly-2il</guid>
      <description>&lt;p&gt;Github: &lt;a href="https://github.com/version-fox/vfox"&gt;VersionFox&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This article mainly introduces a new way to manage multiple versions of Golang, a brand new tool called &lt;code&gt;VersionFox&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;One of the most common problems in daily life is that the company's project uses version &lt;strong&gt;1.18.1&lt;/strong&gt;, but I want to use the latest version &lt;strong&gt;1.21.6&lt;/strong&gt; for my personal project. What should I do?&lt;/p&gt;

&lt;p&gt;Before I developed this tool, it was like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0y8jhdohtgexqs54phzz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0y8jhdohtgexqs54phzz.png" alt="img1" width="800" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For those with obsessive-compulsive disorder, it's quite uncomfortable to look at, right? Also, every time I need to &lt;strong&gt;add a new version&lt;/strong&gt; or &lt;strong&gt;switch versions&lt;/strong&gt;, I have to modify the &lt;strong&gt;.zshrc&lt;/strong&gt; file, repeatedly commenting and adding environment variables.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Also, as you can see, I'm dealing with other languages and tools! This process is even more painful!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So, I decided to develop a more universal version management tool &lt;strong&gt;VersionFox&lt;/strong&gt; (I know there are some ready-made tools available, but haha, keep reading and you'll see).&lt;/p&gt;

&lt;h2&gt;
  
  
  What is VersionFox?
&lt;/h2&gt;

&lt;p&gt;Simply put, it's a &lt;strong&gt;cross-platform&lt;/strong&gt;, &lt;strong&gt;universal&lt;/strong&gt;, &lt;strong&gt;extensible&lt;/strong&gt; SDK version manager~&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cross-platform (&lt;strong&gt;Windows&lt;/strong&gt;, &lt;strong&gt;Linux&lt;/strong&gt;, &lt;strong&gt;macOS&lt;/strong&gt;), providing the same user experience across different platforms&lt;/li&gt;
&lt;li&gt;Manage all languages with consistent commands&lt;/li&gt;
&lt;li&gt;A simple plugin system to add support for the SDKs you need&lt;/li&gt;
&lt;li&gt;Supports &lt;strong&gt;Global&lt;/strong&gt;, &lt;strong&gt;Project&lt;/strong&gt;, &lt;strong&gt;Session&lt;/strong&gt; scopes (important!!)&lt;/li&gt;
&lt;li&gt;When you switch projects, it &lt;strong&gt;automatically switches&lt;/strong&gt; to the corresponding version&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Quick Start
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1.Install vfox
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;VersionFox&lt;/strong&gt; supports multiple platforms (Windows, Linux, macOS). For demonstration, we use &lt;code&gt;Homebrew&lt;/code&gt; for quick installation. (For detailed installation, please see  &lt;a href="https://github.com/version-fox/vfox/wiki/Getting-Started#installation"&gt;Installation&lt;/a&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;brew tap version-fox/tap
&lt;span class="nv"&gt;$ &lt;/span&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;vfox
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hook &lt;code&gt;VersionFox&lt;/code&gt; to your Shell (choose one from the following items that suits your shell)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'eval "$(vfox activate bash)"'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.bashrc
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'eval "$(vfox activate zsh)"'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.zshrc
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'vfox activate fish | source'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.config/fish/config.fish

&lt;span class="c"&gt;# For Powershell users, add the following line to your $PROFILE file:&lt;/span&gt;
Invoke-Expression &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;vfox activate pwsh&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Add Golang plugin
&lt;/h3&gt;

&lt;p&gt;After installing &lt;strong&gt;VersionFox&lt;/strong&gt;, you can't do anything yet, because &lt;strong&gt;VersionFox&lt;/strong&gt; uses plugins as extensions, and you need to install the corresponding plugins first.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Of course, if you don't know which plugins to add, you can use the &lt;code&gt;vfox available&lt;/code&gt; command to check all available plugins&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;vfox add golang/golang
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Install the latest version
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Command&lt;/strong&gt;: &lt;code&gt;vfox install golang@&amp;lt;version&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After the plugin is successfully installed, you can install the corresponding version of &lt;code&gt;Golang&lt;/code&gt;. For example, we use the following command to install the latest version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;vfox &lt;span class="nb"&gt;install &lt;/span&gt;golang@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Switch versions
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Command&lt;/strong&gt;: &lt;code&gt;vfox use golang&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After successful installation, you can freely switch the version of &lt;code&gt;Golang&lt;/code&gt;. Use the following command to select the version you want to switch to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;vfox use golang
&lt;span class="nv"&gt;$ &lt;/span&gt;go version
go version go1.21.6 darwin/amd64
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Scopes
&lt;/h2&gt;

&lt;p&gt;Sometimes, we need to handle multiple projects at the same time. If all projects use the same version, there is no problem. But the reality is often not so ideal!&lt;/p&gt;

&lt;h3&gt;
  
  
  Session Scope
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Only valid within the current shell session, shells are isolated from each other and do not affect each other&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Command&lt;/strong&gt;: &lt;code&gt;vfox use -s golang&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6o1cbg58g6j1ky8450e4.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6o1cbg58g6j1ky8450e4.gif" alt="session scope" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Project Scope
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;A .tool-versions file will be created in the current directory to record the version used in the current project. The scope is limited to the current directory, and the version will automatically switch when the directory is switched&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Command&lt;/strong&gt;: &lt;code&gt;vfox use -p golang&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://imgur.com/a/rU9GGyM"&gt;https://imgur.com/a/rU9GGyM&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4-o4Gq-o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://i.imgur.com/ZeuQoy5.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4-o4Gq-o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://i.imgur.com/ZeuQoy5.gif" alt="project" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Global Scope
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;The scope is global, no need to explain, it's everywhere! 😊&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Command&lt;/strong&gt;: &lt;code&gt;vfox use -p golang&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Other Commands
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Search Command
&lt;/h3&gt;

&lt;p&gt;The current &lt;code&gt;golang/golang&lt;/code&gt; plugin gets version information by parsing &lt;code&gt;https://go.dev/&lt;/code&gt;, keeping in sync with the official version, so there is no delay~&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: So how do we know what the current available versions are (or I just want to see what the top 3 latest versions are)?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer&lt;/strong&gt;: Through the &lt;code&gt;vfox search golang&lt;/code&gt; command, you can view all available versions, support search, and support pagination&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fko5kq1kq3cxem83zlg0w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fko5kq1kq3cxem83zlg0w.png" alt="search" width="800" height="517"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, for easier use, after selecting the target version on the current search page, press Enter to install immediately, no need to execute the &lt;code&gt;vfox install&lt;/code&gt; command again!&lt;/p&gt;

&lt;h3&gt;
  
  
  View Installed Versions
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Command&lt;/strong&gt;: &lt;code&gt;vfox ls golang&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Uninstall Specific Version
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Command&lt;/strong&gt;: &lt;code&gt;vfox uninstall golang@&amp;lt;version&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For more commands, please see &lt;a href="https://github.com/version-fox/vfox/wiki/All-Commands"&gt;All Commands&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By now, I think you've realized the power of &lt;code&gt;VersionFox&lt;/code&gt;. 😄&lt;/p&gt;

&lt;p&gt;Also, as a universal SDK version manager, VersionFox is not limited to Golang, it currently supports multiple languages or tools, for details please see &lt;a href="https://github.com/version-fox/version-fox-plugins"&gt;Plugin Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Come and experience it~ Welcome to use and feedback bugs, if you have good ideas you can also raise &lt;a href="https://github.com/version-fox/vfox/issues"&gt;issue&lt;/a&gt;~&lt;/p&gt;

&lt;p&gt;If you find it helpful, please give us a star🌟🌟, to show your support, thank you 🙏~~&lt;/p&gt;

&lt;p&gt;Github: &lt;a href="https://github.com/version-fox/vfox"&gt;VersionFox&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
