Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Roger Panella
Roger Panella
5,968 Points

Java repl "no unique maximal instance" error

I've installed the Java repl on my machine using Homebrew. I keep getting an error that I don't know how to fix, and am not sure what's producing it. It happens a lot, but here's one way I'm able to produce it:

First, I enter this example from the "Incrementing and Decrementing" video:

java> int example = 1 repl displays: int example = 1

Then, I enter:

java> int example = example + 1

At this point, I get the error:

ERROR: /var/folders/1b/c7kfxf2s4297q8rqqm4x_wsw0000gn/T/JavaREPL/fceec614-9263-4ec1-ac7b-5b7df62de85b/Evaluation.java:7: type parameters of <T>T cannot be determined; no unique maximal instance exists for type variable T with upper bounds int,java.lang.Object public int example = valueOf("example"); ^

Also, once the commands above have produced the error, it seems like everything I enter produces the same error.

For example, if I enter:

java> int example2 = 2

I get this:

ERROR: /var/folders/1b/c7kfxf2s4297q8rqqm4x_wsw0000gn/T/JavaREPL/fceec614-9263-4ec1-ac7b-5b7df62de85b/Evaluation.java:7: type parameters of <T>T cannot be determined; no unique maximal instance exists for type variable T with upper bounds int,java.lang.Object public int example = valueOf("example"); ^

Any ideas? I saw changing the JDK version and also changing the bits as solutions on StackOverflow, but wasn't sure how to do that or if that's what I need to do.

1 Answer

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

My guess is you can't define the variable and increment it in the same go.

int example = 1;
example = example + 1;

Is what you are looking for I think ;)

Looks like you found a juicy bug in the REPL tool!