Yes, you can. Just use full path names when invoking javac, java, etc. or set your PATH environment variable to point to the appropriate jdk/bin location.
The IDEs usually allow defining multiple JDKs/JREs, and you can choose which one to use for every project.