Higher-Kinded Type
Higher-Kinded Type

Reputation: 2054

Java/JRE version change, Errors in Eclipse and more

This might be a very stupid question but bear with me since I am new to Java/J2EE. I have installed JRE6 and JRE7 on my machine. I have set JAVA_HOME environment variable to point to my JRE6 directory. Also, in my eclipse, I have pointed the working JRE to JRE6. However, if run "java -version" in the terminal, it says current java version is 1.7 (pointing to JRE7).

The problem I am actually facing is that eclipse gives me errors for the following iunterface:-

public interface IServiceHelper {
    public <T extends Document> Document SomeMethod(Object obj);

          // Error - Duplicate method SomeMethod(Object) in type IServiceHelper
    public <T extends SomeClass> SomeClass SomeMethod(Object obj);  

          // Error - Duplicate method SomeMethod(Object) in type IServiceHelper
    public <T extends String> String SomeMethod(Object obj);
}

However, a maven build outside of eclipse in a terminal succeeds.

The above interface may not be a good design and may be really some tricky code. Since this is an existing piece of code, I am not supposed to make changes. Please help me find out what is wrong with eclipse and/or JRE version.

Upvotes: 1

Views: 1424

Answers (2)

Maciej
Maciej

Reputation: 140

If you have mess with Java versions on your machine you can easily set up which Java eclipse will use. Edit file /eclipse.ini Add: -vm PATH_TO_YOUR_JAVAW_EXECUTABLE

From Eclipse FAQ: If a JVM is installed in the eclipse/jre directory, Eclipse will use it; otherwise the launcher will consult the eclipse.ini file and the system path variable. Eclipse DOES NOT consult the JAVA_HOME environment variable.

To explicitly specify a JVM of your choice, you can use the -vm command line argument:

eclipse -vm c:\jre\bin\javaw.exe ''start Java by executing the specified java executable

http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F

Upvotes: 0

Oded Peer
Oded Peer

Reputation: 2427

There are a couple of things here:

  1. I assume you are using Windows. See this thread for understanding why it ignores your JAVA_HOME - Windows ignores JAVA_HOME: how to set JDK as default?
  2. Using the same method name and arguments with a different return type is forbidden in Java, see a discussion here so in java you can't have duplicate method names with different return and params?
  3. Your maven build works? Interesting. Can you run 'clean' before building, build in debug and share the results?

Upvotes: 2

Related Questions