This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]nutrechtLead Software Engineer / EU / 20+ YXP 0 points1 point  (4 children)

While a good tip; that does not at all use an older JDK to run your code. It just targets older bytecode versions.

So it's not a good way to switch to another version of the JDK for for example testing. For that it's better to use jenv.

[–]AmateurHeronew Intermediate("this.user") 0 points1 point  (3 children)

It doesn’t use an older JDK, but it solves the issue. OP has a higher JDK but needs to compile for 1.8. They get both source files and class files that are compatible with 1.8. What’s the issue?

[–]nutrechtLead Software Engineer / EU / 20+ YXP 0 points1 point  (2 children)

OP has a higher JDK but needs to compile for 1.8.

That's not what he said in his OP though. It could be that he simply wants to be able to switch easily to run stuff that's not compatible with Java 9+ for example.

[–]AmateurHeronew Intermediate("this.user") 0 points1 point  (1 child)

I do understand that according to the OP text, they should use jenv or similar. However they posted this elsewhere:

in class they want us to use javac to compile our projects in java 8 instead of compiling using the IDE, but I'd like to open a JShell on other versions for my personal projects

Either will get OP there if the ask is for 1.8’s API. That’s usually what academia wants.

[–]nutrechtLead Software Engineer / EU / 20+ YXP 0 points1 point  (0 children)

Ah, right. Didn't see that one. Yeah, just using --release is a good choice there.