Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: How to change default eclipse compiler

  1. #1
    Join Date
    Oct 2010
    Location
    California, US
    Beans
    89
    Distro
    Ubuntu 14.04 Trusty Tahr

    How to change default eclipse compiler

    Hi all. I have been having consistent problems with my eclipse IDE as many of the packages are not recognized. Notably the java.util.Scanner isnt working at all. I later found the reason for the problem that my eclipse takes openjdk compiler as default even though I have changed my default system jdk to be sun. Also I have gone Windows -> Preferences -> Java -> Installed JREs and have added the path of my sun-6 jdk (which is /usr/lib/jvm/) and have made it the default one in eclipse by checking on the box against it. But it is really frustrating to see the compiler not recognize my code. Can anyone kindly temme how to change the default compiler? I'm not an expert in this, so well explained help will be deeply appreciated.

    Kindly see below for my java and its compiler versions:


    Code:
    najdorf@mynatty:~$ java -version
    java version "1.6.0_24"
    Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
    Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)

    Code:
    najdorf@mynatty:~$ javac -version
    javac 1.6.0_24

    Also when I compiler the message in status bar just before comsole in eclipse window is attached below


  2. #2
    Join Date
    Oct 2010
    Location
    California, US
    Beans
    89
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: How to change default eclipse compiler

    ^Bounce! Someone kindly help

  3. #3
    Join Date
    Sep 2010
    Location
    Gurgaon, India
    Beans
    553
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: How to change default eclipse compiler

    are you sure this is the case of your default compiler being openjdk and not something else?

  4. #4
    Join Date
    Oct 2010
    Location
    California, US
    Beans
    89
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: How to change default eclipse compiler

    Quote Originally Posted by kanishkdudeja View Post
    are you sure this is the case of your default compiler being openjdk and not something else?
    I'm sorry I don't get your question. My default Java is Sun JDK as shown below

    Code:
    najdorf@mynatty:~$ java -version
    java version "1.6.0_24"
    Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
    Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
    But eclipse compiles my program with Openjdk even though I changed it's settings in Windows -> Preferences -> Java -> Installed JREs

    When I searched for this online I learnt that the possible cause could be the version of javac compiler that the system has. I wanna know how you could change the default javac in Ubuntu. My current one is as shown below

    Code:
    najdorf@mynatty:~$ javac -version
    javac 1.6.0_24

  5. #5
    Join Date
    Sep 2010
    Location
    Gurgaon, India
    Beans
    553
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: How to change default eclipse compiler

    okay..

    Right click on the project..click on build path..click on configure..then select the sun java one there..

    if it still doesnt work i have an idea..

    you can remove openjdk from your system..
    then eclipse will be forced to use sunjdk as the default jdk..

  6. #6
    Join Date
    Oct 2010
    Location
    California, US
    Beans
    89
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: How to change default eclipse compiler

    Quote Originally Posted by kanishkdudeja View Post
    okay..

    Right click on the project..click on build path..click on configure..then select the sun java one there..
    U mean where? I didn't get it.

    When I right click on a project (a simple java project) then goto Build path -> Configure Build Path, I don't see a way to change my compiler option to Sun java. Can u explain?

  7. #7
    Join Date
    Sep 2010
    Location
    Gurgaon, India
    Beans
    553
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: How to change default eclipse compiler

    Check the image ive attached below..

    You will see a similar image when you click on Configure Build Path..

    Now click on libraries..

    If you see any open jdk entries there, remove it..

    If you don't see the JRE SYSTEM LIBRARY [ JavaSE 1.6 ] like it is shown for me, click on the Add libraries option.

    Then Click on JRE System Library option..Then click on Alternate JRE..After clicking of Installed JRE's click on the sun java jre one..open jdk entries if you you find them there..this will not uninstall open jdk from your system just will remove them from the eclipse configuration..you can add it later if you want to..

    After selecting the Sun jre from the list(you can check the second screenshot)..click on ok..

    then click on finish..and then click on okay..

    i think that should work..and then recompile your project
    Attached Images Attached Images

  8. #8
    Join Date
    Sep 2010
    Location
    Gurgaon, India
    Beans
    553
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: How to change default eclipse compiler

    were you able to solve it?

  9. #9
    Join Date
    Oct 2010
    Location
    California, US
    Beans
    89
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: How to change default eclipse compiler

    It didn't solve my basic problem of compiling the code without indicating 'Scanner' as an error but it did change my installed JRE and I was able to remove openjdk from the list. See attachment (screenshot of Windows -> Preferences -> Java (Installed JREs).
    I was wondering if making sun java the default automatically sets the system to look for its updates? I mean when u do

    Code:
    sudo update-java-alternatives -s java-6-sun
    Attached Images Attached Images

  10. #10
    Join Date
    Sep 2010
    Location
    Gurgaon, India
    Beans
    553
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: How to change default eclipse compiler

    Does your code work normally with the command line? With javac and java commands?

    If it doesnt work, we can be sure its a problem with the jre and not eclipse.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •