The Manticore version of myrobotlab requires Java 8.
The Nixie version of myrobotlab requires Java 11.

What do you do ? 

Make it so you can start either and select the Java version just before starting myrobotlab.
Both versions of Java need to be first installed on the computer.
Some details differ between Windows, Linux and Mac - but the basic concepts are the same.
Here are the steps.

  • Install both/all versions of Java you will want to use - for this tutorial it will be just 8 & 11
  • Make sure there is no "default" version - we don't want "any" version running by default
  • Set the appropriate envronment variables to start Java 8 or Java 11
  • Start the appropriate version or myrobotlab

So now in detail (for Windows 10 x64):
 

Install All the Versions of Java You will want to use (we will do 8 & 11)
https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html 
https://www.oracle.com/java/technologies/javase-jdk11-downloads.html

download the 8 exe

/sites/default/files/users/user3images/Selection_139(1).png

and the 11 compressed archive

Getting access to these links now requires you to have an account with Oracle.

The reason we tooked the 11 compressed archive, is because the .exe does things we will have to "undo".

Lets install 8:

I don't like the installer installing under C:\ProgramFiles\...
I prefer all the java be installed under a directory called java\{version}
But its personal preference, it is nice to go to one place and see what all the different versions you have.

It then asks you where you want the JRE installed.
The JDK and JRE are more or less the same thing.  The slightly different part is the JDK has more stuff.  It has stuff for developing new Java applications, the JRE has only stuff for running Java applications. Anyway, it wants to install under C:\ProgramFiles .. but I just make a new folder under c:\java\  called jre1.8.0_291

Start a command prompt.  Type in java -verson 

NOOOOOOO !!!!!

You may think this is a good thing, but its not for what we are trying to do.  
When we open a new command prompt and type java ... what we want is:

When I typed "where java" it gave us the path were its using the default one.  Let's get rid of it.
You need to remove it from your environment variables.  Start by typing environment in the search box at the bottom left of the screen.

Bring up System Properties, Press Environment Variables, highlight Path under System variables, then press edit.  Hightlight the evil C:\Program Files (x86)\Common Files\Oracle\Java\javapath
and Delete it !  Hit "Ok" in all the open dialogs.

To verify life is good. Open a new Command Prompt and type java -version
Hopefully you see this:

If java is found.. you type "where java" and go back to the environment variables to take it out of either 
User variables Path, or System variables Path.

The other environment variable you want to remove completely if it exists is JAVA_HOME.

At this point you should have several folders of different versions of java, but java is no worky on the command prompt.  That's a good place to be.  Less magic and hidden variables.

Starting Manticore

Download manticore to a new directory
http://repo.myrobotlab.org/releases/myrobotlab.1.0.2693.16.zip
unzip it.
I unzipped it into C:\
Start a Command Prompt
Go to the directory you unzipped Manticore version.  cd C;\
Type "java -version" and make sure it can't find java.

Now do the following:

The set command, sets environment variables - Just like the ones we removed.  But in this case the command

set PATH=%PATH%;C:\java\jdk1.8.0_291\bin

sets the current PATH variable to what it currently is PLUS the location of the executables of java 1.8 was installed.

PATH is an important environment variable.  Windows, Linux and Mac all have and use this variable. It's the list of directories the operating system uses when you type a command.  The operating system will search through all of the directories listed to try to find a match to run.

You can modify the variable with a command called "set" on Windows

set PATH=%PATH%

means set my PATH variable to whatever it is now.
You can check what it is now by typing

echo %PATH%

You should see a whole bunch of directories separated by a semi-colon ; And these are all the directories that are searched. So:

set PATH=%PATH%;C:\java\jdk1.8.0_291\bin

Add's our Java 1.8 directory and now we can run Java 1.8 applications like manticore.

Now type the following in C:\myrobotlab.1.0.2693.16

java -jar myrobotlab.jar 

How long does this last ?  As long as you keep using the command prompt where you did the 
set command.  It only effects that command prompt AND anything that is started from that command prompt.
So right now its a Java 8 command prompt.

Lets make a Java 11 command prompt.  
Start a new command prompt from the windows search 

Make sure java -version doesn't work

Then do the magic set command but this time use the path where the Java 11 exes exist

set PATH=%PATH%;C:\java\jdk-11.0.9\bin

You now have a Java 11 command prompt, you can start Nixie !
Look !  Java 8 and Java 11 Manticore and Nixie running at the same time on the same computer !

You can get really fancy and make shortcut commands or batch files which automatically start a Java 8 or Java 11 or whatever version your interested in running.

For shortcuts:
https://netlicensing.io/blog/2012/06/15/set-environment-variables-in-windows-shortcut/

If you want to do 2 batch files and put them somewhere convienent, make sure the "paths" are correct
for your system.
contents of j11.bat

echo setting java 11 environment

set PATH=%PATH%;C:\java\jdk-11.0.9\bin
REM this start an cmd shell with the appropriate env
cmd /k
REM you can get more elaborate if you want
REM cd to where Nixie is 
REM java -jar myrobotlab.jar 
 

contents of j8.bat

echo setting java 8 environment

set PATH=%PATH%;C:\java\jdk1.8.0_291\bin
REM this start an cmd shell with the appropriate env
cmd /k
REM you can get more elaborate if you want
REM cd to where Manticore is 
REM java -jar myrobotlab.jar 

 

Potentially there is no end to how fancy and elaborate you can get - 
Happy Coding !

hairygael

3 years 4 months ago

Oh wow!

Thanks Grog that's a real tutorial, no doubt this has taken you a lot of time to do.

Now it all seems so simple to have both java working on my PC.

wvantoorn

3 years 3 months ago

Also make sure to check that when using a newer java version, say java 11.0.11 that that is correctly in your path.

In the examples it says 11.0.9 but we are already to 11.0.11

so it would become: 

set PATH=%PATH%;C:\java\jdk-11.0.11\bin instead of

set PATH=%PATH%;C:\java\jdk-11.0.9\bin