How to use multiple Java versions at the same time?

  Рет қаралды 9,490

Apply IT

Apply IT

Жыл бұрын

#applyit #java #jdk #jdk18 #jdk8 #jdk19
When we are working on multiple java projects at the same time, we need both java versions available. However changing environment variable frequently is not efficient approach. This video demonstrates how can we automate setting a required java version. We just need to run one command to set the required java version and within a second, the desired java version becomes available.
This video answers the following questions:
How to run multiple versions of Java on the same machine
How to run multiple versions of Java on Windows
How to run multiple versions of Java on Linux
How to run multiple versions of Java on Ubuntu
How to run Java 8 and Java 18 simultaneously
Can we run two Java versions simultaneously
Can we run two Java versions at the same time
How to switch from one java version to another
How to switch from Java 8 to Java 18 using command prompt
Switch between Java versions using batch command
How to work with different Java versions simultaneouly

Пікірлер: 47
@vp_bot
@vp_bot Жыл бұрын
needed this to run multiple minecraft servers on different versions.
@GameLifeYT
@GameLifeYT Жыл бұрын
does this still work for you as of java 20
@ApplyIT2021
@ApplyIT2021 Жыл бұрын
It should. It works for 19.
@_Shotox_
@_Shotox_ 10 ай бұрын
did following this allow you do do it im currently trying to get a 1.12 server and a 1.20 running at the same time and im pulling my hair out trying to get it working
@vp_bot
@vp_bot 10 ай бұрын
it did but turns out you can just use java 17
@ApplyIT2021
@ApplyIT2021 10 ай бұрын
@@_Shotox_ I used it for three different JDK: JDK 8, Amazon Corretto jdk11.0.18_10, and JDK 19. It worked for all. We can use one particular version on one command prompt or terminal.
@isi24.8
@isi24.8 Жыл бұрын
Very useful tip.. Thank you very much
@ApplyIT2021
@ApplyIT2021 Жыл бұрын
Thanks for your feedback.
@avdhutnula9675
@avdhutnula9675 9 ай бұрын
Helpful content!
@ApplyIT2021
@ApplyIT2021 9 ай бұрын
Glad it was helpful!
@ApplyIT2021
@ApplyIT2021 Жыл бұрын
Switching from one java version to another is very quick with writing such command script file.
@AswinA-z1l
@AswinA-z1l 4 күн бұрын
Very useful tip
@ApplyIT2021
@ApplyIT2021 2 күн бұрын
Glad you liked it
@manishtiwari1823
@manishtiwari1823 4 ай бұрын
Thanks, Buddy.
@ApplyIT2021
@ApplyIT2021 4 ай бұрын
Welcome!
@nurhaslina4129
@nurhaslina4129 7 ай бұрын
best tutorial..
@ApplyIT2021
@ApplyIT2021 7 ай бұрын
Thank you for your feedback!
@msnraju97
@msnraju97 Жыл бұрын
🤓 smart work is better than hard work
@ApplyIT2021
@ApplyIT2021 Жыл бұрын
Correct.
@safkaify7875
@safkaify7875 12 күн бұрын
How does windows detect the C:\Tools folder to pickup the changes from jdk8.bat and jdk18.bat files. It seems what you are showing is all in the same folder. Your changes are only for the current CLI session, correct?
@ApplyIT2021
@ApplyIT2021 12 күн бұрын
If we set PATH of java/javac as environment variable, we can put any one (JDK 8 or JDK 18) at front. So always, javac from a specific version will be invoked. If you do not want to change this PATH variable everytime you switch from a project using JDK 8 to a project using JDK 18, or vice versa, you need some efficient solution, which this video provides. And change will be for CLI session, which we want as we want to use specific Java version.
@SDET_QA_Eng
@SDET_QA_Eng Ай бұрын
Thanks alot sirji .jumping from java8 to java 21 was getting me headache with trick its just type cmd.
@ApplyIT2021
@ApplyIT2021 Ай бұрын
I feel Happy that it helped you!
@rimbaud1982
@rimbaud1982 9 ай бұрын
And what is the content of the other files? Carnac, cloc, cloc-1.64, ngrok?
@ApplyIT2021
@ApplyIT2021 9 ай бұрын
Those are other tools: cloc is for counting Lines of Code in a software project or in files, ngrok is for tunneling, and Carnac is keyboard utility.
@rimbaud1982
@rimbaud1982 9 ай бұрын
Ok, I understand, but I need to know how to make these files or you can show their content and put it in my project
@ApplyIT2021
@ApplyIT2021 9 ай бұрын
@@rimbaud1982 These are utilities available at the following sites: sourceforge.net/projects/cloc/ ngrok.com/ carnackeys.com/ After placing the downloaded binaries in any folder say, C:\Tools, we need to include that path C:\Tools in PATH environment variable. So we can access from any directory while working with command prompt.
@avinashjha3127
@avinashjha3127 4 ай бұрын
i am unable to switch from jdk17 to jdk 8,even if i execute jdk8 command it runs jdk17.i am not using openjdk,i am using JDK 17
@ApplyIT2021
@ApplyIT2021 4 ай бұрын
In the jdk8 batch that we create, the path for jdk8 has to be at the front. If the path for jdk8 has been placed after existing PATH, and the existing PATH already includes the path for jdk17, then this problem can occur.
@rodrick89
@rodrick89 Жыл бұрын
I'm junior and starting out. I created the two batch files. The jdk7.bat and jdk11.bat (in my case.) I try to run it on my command prompt on windows and it doesn't work. It gives me the following error: 'jdk11' is not recognized as an internal or external command, operable program or batch file. The same is thrown for jdk7.bat. Anyone?
@ApplyIT2021
@ApplyIT2021 Жыл бұрын
You need to set path of the folder (I placed those .bat files in C:\Tools) containing .bat files in environment variable (PATH)
@arryaanjain6804
@arryaanjain6804 11 ай бұрын
Hey@@ApplyIT2021 despite setting it, I am still facing the same error.
@pratyushshahi972
@pratyushshahi972 5 ай бұрын
​@@ApplyIT2021It doesn't show any tools file in c folder
@ApplyIT2021
@ApplyIT2021 5 ай бұрын
@@pratyushshahi972 That Tools directory is not a standard directory; you need to create it and can place all additional custom executables/batch files (tools ) under that and set PATH environment variable of Tools. Then, you will be able to access all executables from terminal.
@pasindupabasara1293
@pasindupabasara1293 9 күн бұрын
Bro it's worked. Can I use this for my blog (develop this method and try my new ideas)
@ApplyIT2021
@ApplyIT2021 7 күн бұрын
You can use it. It is expected that at some point in your blog you should reference this video, in scientific term it is called citation.
@pasindupabasara1293
@pasindupabasara1293 7 күн бұрын
@@ApplyIT2021 ok brother ❤️
@GameLifeYT
@GameLifeYT Жыл бұрын
does this still work as of java 20?
@ApplyIT2021
@ApplyIT2021 Жыл бұрын
Yeah. It should.
@user-cc7nx2fz7s
@user-cc7nx2fz7s 8 ай бұрын
On my operating system I did exactly as in the video and it didn't work
@ApplyIT2021
@ApplyIT2021 8 ай бұрын
On windows system, only two steps to perform for setup: 1. Write a .bat file. 2. Include path of .bat file in PATH environment variable. To test the setup, open a new command prompt and just write name of the .bat file (without extension). It should work. What did not work on your system?
@TreeLuvBurdpu
@TreeLuvBurdpu Жыл бұрын
That's all in the same folder. You're changes are only for the current CLI session.
@ApplyIT2021
@ApplyIT2021 Жыл бұрын
We want that we have different JDK versions for different java projects. As changing environment variable will affect to all CLI sessions and we do not want that.
@TreeLuvBurdpu
@TreeLuvBurdpu Жыл бұрын
@@ApplyIT2021 different Java projects? All in D:/? Usually people put different projects in different folders.
@kenb1
@kenb1 10 ай бұрын
@@TreeLuvBurdpu It was only for demonstration purposes, showing that different CLI sessions can run different JDK's, even if from same folder. In reality of course there would be different projects in sub folders, and not from the root of the D-drive.
Java Is Better Than Rust
42:14
ThePrimeTime
Рет қаралды 128 М.
Smart Sigma Kid #funny #sigma #comedy
00:26
CRAZY GREAPA
Рет қаралды 18 МЛН
Gym belt !! 😂😂  @kauermtt
00:10
Tibo InShape
Рет қаралды 16 МЛН
How to switch multiple Java versions in Windows the Easy Way
4:08
AMD Almost Went Bankrupt…but were saved by Sony and Microsoft?
5:35
How to Use LAMBDA Function in Google Sheets
8:12
Apply IT
Рет қаралды 499
Mac Fanboy Tries ARM Windows Laptops
31:40
Snazzy Labs
Рет қаралды 167 М.
So... why did AI take off now?
4:01
HGModernism
Рет қаралды 263
Can we dooby Tesco's GU10 bulbs?  - with schematic
10:41
bigclivedotcom
Рет қаралды 58 М.
Nhảy bất chấp/kỳ kỳ tv & Family #shorts
0:16
Kỳ kỳ tv & Family
Рет қаралды 16 МЛН
Готовим дошик-ролл за решеткой... с @samsebesushist
0:40
Кушать Хочу
Рет қаралды 1,9 МЛН
宠爱天使的小丑。#天使 #小丑 #超人不会飞
0:20
超人不会飞
Рет қаралды 10 МЛН