• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Preparing for Java SE17 Developer using Java 21 JDK. Potential problems?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I just bought the Selikoff's study guide and I like it a lot. Only one question. I already have the Java 21 jdk installed and I'm doing some projects with it. I know that in an ideal situation I need to prepare for the exam using the exact same version of Java. But since I'm doing the strudying and development at the same time, I wouldn't like to switch between the versions every time.

Are you aware if there is any considerable difference between the 17 and 21 versions that could impact my preparation? Or can I just stick with the 21 for now?

Thank you in advance,
Mark
 
Enthuware Software Support
Posts: 4885
60
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are a few differences between the two but all of them can be identified easily (switch patterns, record patterns, virtual threads, and sequenced collections). A Java 17 book will not have references to these new features of Java 21 and all of the features of Java 17 are supported by Java 21. So, no need to switch the JDK.

As an alternative, you may consider preparing for OCP Java 21 as well because by the time you will be done with your OCP Java 17 preparation, OCP 21 may be out (not confirmed but likely).
 
Master Rancher
Posts: 5060
81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would nonetheless encourage you to try intalling JDK 17 in addition to JDK 21.  I recommend the sdkman tool for this - at least if you're on a Mac or Unix.  It also runs on Windows, and it probably works fine here too; I just don't have experience there to recommend it.  Using sdkman it becomes quite easy to have multiple versions of Java on your machine, and switch between them easily.  I use it to configure a JDK version for particular directories, so that I can have one Java 21 project directory where any time I go to that directory, it sets the JDK version to a particular JDK 21 installation, while resetting it to JDK 17 whenever I'm anywhere else (since that's the version I need for work).  The sdkman tool makes this pretty easy to set up.
 
Mike Simmons
Master Rancher
Posts: 5060
81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since you're using JDK 21 as your base, you can also run java using the --source flag, e.g.

javac --source 17 MyClass.java

That way it will use Java 17 language features only, even though you're running JDK 21.  I'm not sure whether it also limits the standard library features you can use.  It didn't use to, but I think it may now.

If you're using an IDE, it should also be possible to configure the IDE to do the same thing for you.

 
It's feeding time! Give me the food you were going to give to this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic