Forum Discussion

Marco2's avatar
Marco2
New Contributor
2 years ago

CertificateFactory.getInstance("CV")

I need a CertificateFactory for "CV" in a Groovy script. How can I set up a suitable Java version, for example java-17.

  • richie's avatar
    richie
    Community Hero

    Hey Marco2 

     

     

    Sorry if I'm missing the point here - but are you just asking how to setup/install a different version of java to ensure your groovy is using the correct version of Java runtime you need?

     

    Cheers,

     

    Rich

    • Marco2's avatar
      Marco2
      New Contributor
      Hello Rich,

      yes, I think that would solve my problem.


      Best regards
    • richie's avatar
      richie
      Community Hero

      Hey Marco2 

       

      Have you confirmed which version of Java is "suitable"?  If you explain what you need to do, this might help - libraries get deprecated across Java versions so you wanna make sure you pick the correct version of Java - so if you explain what you're trying to do this might help.

       

      Anyway - for say you want Java 17 - search for JDK 17 and download it.  BTW - you get JRE 17 and JDK 17.  Always download the JDK in regards to ReadyAPI! usage.  The JDK includes additional stuff that enables you to debug your groovy scripts, the JRE option doesn't.

       

      Anyway - once you've installed the JDK, restart your machine and (I'm guessing you're running Windows) - open a command prompt window and type at the prompt>

       

      'java --version' <RETURN>

       

      This will tell you if your laptop/PC is pointing at JDK 17 or another version of Java runtime you already have installed.

       

      To repoint your Java and PATH Windows environment variables to the JDK v17, do the following:

       

      To set the variables you can use the commandline, but it's easier just to do it via the Windows form --> go to Control Panel > System > Advanced system settings > Advanced > Environment Variables.  Look in the System Variables.  

       

      Ok - right - so if you have more than one version of Java installed, and depending on the application that is using the Java - you might need to create the JAVA_HOME environment variable.  ReadyAPI! doesn't need the JAVA_HOME path variable set - HOWEVER - it  has helped me control which version Windows sees if you have more than 1 version of Java installed (even though this should just be the PATH variable - dont ask - this was just trial and error!)

       

      Anyway - we're gonna create a JAVA_HOME (if it doesnt already exist) and update the PATH variable

       

      JAVA_HOME: stores location of the JDK’s installation directory and is used by certain applications like Eclipse, but isn't necessary to be set for ReadyAPI - however setting it fixed a Java clash version I had - so I'm including it in these instructions anyway

       

      Within the System Variables - click on 'New' and then set the name to JAVA_HOME and the value to wherever you installed the JDK - hopefully C:\Program Files\Java\jdk1.7.0

       

      PATH: stores paths of directories where the operating system will look, to launch the requested programs quickly. 

       

      With the PATH variable - it's already got loads in there - you are ADDING to the content already in there - you aren't replacing the content cos you'll break other stuff

       

      So - click on the 'PATH' system variable and click on the 'Edit' button in the form.  This launches a form entitled 'Edit environment variable'.  Click on 'New' - this enables a new row in the list.  Paste in the new row the value 'C:\Program Files\Java\jdk1.7.0\bin'

       

      I always tend to restart my machine whenever I mess around with System/Environment Variables - dunno whether it's absolutely necessary or not - just do it anyway.

       

      Once you've restarted your machine, launch a command prompt window and then at the prompt run 'java --version'

      Ensure it says the correct version and that's it!

       

      Cheers,

       

      Rich