Friday, November 8, 2013

Eclipse : A Java Exception has occured

A Java Exception has occurred



Make sure you have you have the latest version of JRE installed in your system.


If the problem still persists then ,the reason being the JRE’s of your system might not be added to the project under consideration. Please follow the steps below .
1)      Eclipse Tool Bar>Window>Preferences> Java>Installed Jre’s.
2)      You should be seeing the path of the JRE installed.Now copy the location of installed JREs
3)      Close the window.
4)      Select your Project>Rt ck >Properties>Java Build Path
5)    In Libraries tab >  clk Add library button
6)      In Add Library Window>Select JRE System Library option>next
7)      In JRE System Library window >clk on Installed JREs > (you should be able to see the path of the insatlled JREs)  Select the JRE  path   
8)      Finish

OR

Other Things done if the above did not solve the problem : -
  A ) Eclipse Tool bar > Project >Clean
OR
  • Code view >Rt click>Run as Config
  • Select Java Application >select  java file containing main function >check all the check boxes in project
OR

  • §  right click project folder > properties
  • §  java compiler
  • §  select 1.7 (or whichever is relevant )

4 comments:

  1. http://seleniumonlinetrainings Selenium Online training from India, Selenium Online Classes Duration 20 Days With 2 months free Selenium with Java Programing training Videos, Manual Testing Training Videos , Selenium and JAVA Configuration Support on your system.

    ReplyDelete
  2. thanks alot Sir,you just made my day,finally i can now live happily wid my eclipse.

    ReplyDelete


  3. I am trying to run the below program

    import org.openqa.selenium.*;
    import org.openqa.selenium.firefox.*;

    public class newClass {

    public static void main(String[] args) {
    // TODO Auto-generated method stub

    WebDriver driver = new FirefoxDriver();
    driver.get("http://google.com");
    }
    but it is showing java exception has occurred and I applied above method to sort out this problem
    but it is not working,please give the solution regarding this problem.

    I also want to mention that that I installed latest java version then eclipse IDE and the selenium new version and then add libraries

    Below is exceptions

    Exception in thread "main" java.lang.UnsupportedClassVersionError: org/openqa/selenium/WebDriver : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
    at java.lang.Class.getMethod0(Unknown Source)
    at java.lang.Class.getMethod(Unknown Source)
    at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

    ReplyDelete
    Replies
    1. This is not the problem with ur code .The problem is mostly with your version either Java,JDK ,eclipse complier or Selenium Webdriver or Your Browser .Do some search on "Unsupported major.minor version 52.0" in google or stackoverflow .

      I would start from here "http://stackoverflow.com/questions/22489398/unsupported-major-minor-version-52-0"

      "http://stackoverflow.com/questions/24790834/cant-fix-unsupported-major-minor-version-52-0-even-after-fixing-compatibility"

      Delete