• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trouble after instantiation of a method  RSS feed

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What am I doing wrong?  I get a Java exception occurred error when I run this. 
It has something to do with the driver.get(url); line of code.
I don't know enough to capture errors and display or handle them yet.
Can you tell me my mistake?
Thanks,
Kevin

 
Master Rancher
Posts: 2570
30
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I get a Java exception 


Please copy the full text of the error message and paste it here.
 
kevin Abel
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Norm,
It makes sense that I should have included the log.  I can see that something is wrong with a version of something.  I'll guess it is Selenium, Java, or the Chrome Driver. 
If you cannot tell from the log what is possibly wrong I can start collecting the files I'm using for the setup. 
Thanks,
Kevin
 
Norm Radder
Master Rancher
Posts: 2570
30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, go ahead and copy the full text of the error message and paste it here so we can see it.
 
kevin Abel
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now when I run it is saying "Java exceiption has occurred."

It was suggested to me from my training school that I change the settings to:
Project -> Properties -> Java Compiler Enable project specific settings. Then select Compiler Compliance Level to 1.8, 1.8 and 1.8 as per the jdk version that you have instaled in your system, build and test your app

It seems to make things worse because I am getting the error message when I try to run other scripts in Eclipse that used to work.

Exception in thread "main" java.lang.UnsupportedClassVersionError: module3/Module3_Assignment : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
HW3-Question.JPG
[Thumbnail for HW3-Question.JPG]
Changing Compliance Level
 
Norm Radder
Master Rancher
Posts: 2570
30
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a mismatch between the installed version of java and the version used to create the class file.
See: https://stackoverflow.com/questions/22489398/unsupported-major-minor-version-52-0

If the class file was created with version 8, it can't be executed with version 7 of  the java program.  The yellow flagged message in the image says currently  1.7
 
Marshal
Posts: 57274
175
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That problem is usually caused by a newer version of javac than the version of java. Please try the following instructions at the command line:-You will probably have to alter your system PATH to correct that problem, so look through your PATH for folders which might contain Java® runtimes.
 
kevin Abel
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am reading the yellow upside down yellow triangle and i see what you are talking about.  I don't know enough to fix it.  i can click on the links in the message and see if it gives some clues of what to do.
 
kevin Abel
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:That problem is usually caused by a newer version of javac than the version of java. Please try the following instructions at the command line:-You will probably have to alter your system PATH to correct that problem, so look through your PATH for folders which might contain Java® runtimes.



Campbell,
Java says 1.8.0_151 and other lines that mention build of the same numbers.

javac says 1.8.0-151

Path contains c:\program files\java\jdk1.8.0_150     I have to look again for the JRE.  

Thanks,

Kevin
 
Norm Radder
Master Rancher
Posts: 2570
30
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Path contains c:\program files\java\jdk1.8.0_150


If that is a complete path from the Path variable, it does not reach to the bin folder where the javac.exe file is so the OS would not be able to find the javac.exe file to be able to execute it.

Check the contents of Path again.  Also look for another path for any java programs so the OS can find the java.exe file.

Also why do the -version responses say 151 but the path says 150?
 
kevin Abel
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here are some images of the path for System variables.
java-install-version-mixup.JPG
[Thumbnail for java-install-version-mixup.JPG]
java version mixup
 
author & internet detective
Sheriff
Posts: 37820
582
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eclipse has a setting for the JDK it uses independent of the system variables. Go to Eclipse preferences > Java > Installed JREs.

Can you show a screenshot of that. In particular, confirm the default is a Java 8 JDK (not JRE).
 
kevin Abel
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did not see:
Eclipse preferences > Java > Installed JREs.
in the Selenium Menu and I could not find a file with the name eclipse preferences.
i found an answer on Stack Overflow that showed how to export the files.  Code ranch won't allow me to attach an .epf file so I pasted the contents below.    I see it mentioning 1.7 and not 1.8.  I"m going to go to sleep now.  I will check the thread tomorrow.   Also I see that you copies the thread from the Java area to here.  i don't know how you did that.

#Fri Feb 02 23:33:42 EST 2018
\!/=
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.compliance=1.7
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.source=1.7
/instance/org.eclipse.jdt.launching/org.eclipse.jdt.launching.PREF_VM_XML=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\r\n<vmSettings defaultVM\="57,org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType13,1462756018616" defaultVMConnector\="">\r\n<vmType id\="org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType">\r\n<vm id\="1462756018616" name\="jdk1.7.0_45" path\="C\:\\Program Files\\Java\\jdk1.7.0_45"/>\r\n</vmType>\r\n</vmSettings>\r\n
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.formatterprofiles.version=12
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/>
@org.eclipse.jdt.core=3.13.0.v20160913-0926
@org.eclipse.jdt.launching=3.8.200.v20160627-1834
@org.eclipse.jdt.ui=3.12.100.v20160910-0421
file_export_version=3.0
 
kevin Abel
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The path is now 151 and reaches the bin folder.

I don't know what is wrong with my Java / Eclipse set up.

Thanks,

Kevin
 
kevin Abel
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error is shown on the Attachments tab.
Thanks,
Kevin
Java-error-message.JPG
[Thumbnail for Java-error-message.JPG]
Java error message
 
Ranch Hand
Posts: 34
Java Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try changing the run configuration to have JDK/JRE 1.8 as a runtime for execution of your project ?
 
Sheriff
Posts: 4526
128
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I did not see:
Eclipse preferences > Java > Installed JREs. 


While Eclipse is running, look for the pulldown menu Windows and select Preferences.  From there, expand the Java node, then click on Installed JREs.
 
Saloon Keeper
Posts: 19007
80
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java allows multiple JDK and JVM versions to be installed on a single computer. Eclipse allows you to use any and all of them on a per-project basis. See Knute's comment.

Additional to the JDK versions that projects can use, Eclipse is written in Java, so there's another possible JDK version. I don't think that the JDK that Eclipse runs under has to actually be an installed (project-usable) VM, but that's certainly the common case. Especially if you only have one version of Java installed on your machine to begin with!

It's actually dead easy to install a JVM. Their base format is a simple ZIP file, so you can download and unzip it and you're good to go. Some distros, such as the Red Hat RPM package go one step further and add links to make it more compliant with local OS conventions, but that's just icing and doesn't afffect the base layout. The Red Hat convention is to make the different JDK and JVM directories under /usr/java, but Java doesn't actually care where you put it, as long as the apps have been told where to find it. JAVA_HOME is a popular environment variable often used for that purpose - although it's not actually part of any official spec.

Once you've installed Java, you can configure it as an available compiler as Knute indicated (in other words, you give it an identifying name and the path to that directory) and/or you can configure Eclipse to start up under it.

So the whole thing is actually fairly simple and the only real issue is if you do something like attempt to employ a plug-in that requires a newer version of Java than the one you're running under.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!