• Post Reply Bookmark Topic Watch Topic
  • New Topic

date import not recognized  RSS feed

 
Jason Attin
Ranch Hand
Posts: 234
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys I have java 8 installed on my machine

but I don't get java to recognize the date import
I have this application and it doesn't compile:
import java.time.*;

it comes back saying that


In my path variable I have, among the other things

Does anybody know why this doesn't work?
thanks
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The class / package that you are trying to use requires Java 8. Do you have a Java 8 JDK in the path?

[EDIT: You have to have it earlier in the path, as the OS will choose the first "javac" that it finds]

Henry
 
Jason Attin
Ranch Hand
Posts: 234
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, I had no idea it had to be before java 7 and not after, thanks, yes now it works. So basically I can remove java 7 from the path altogether, or does it have to be there for when I use eclipse?
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can configure Eclipse to be aware of multiple JDK versions on your machine. This allows you to choose different JDK versions for different projects.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remove Java 7 from your PATH, it's not a good idea to have both Java 7 and Java 8 in your PATH, this might mix things up, which leads to strange errors, as you have experienced.
 
Jason Attin
Ranch Hand
Posts: 234
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys.
Remove Java 7 from your PATH

We haven't moved completely to java 8 as yet, so there are some projects that require java 7 and some others that requires 8 instead
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's when your projects should control what version to use, and not the PATH.
 
Jason Attin
Ranch Hand
Posts: 234
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's when your projects should control what version to use, and not the PATH.
fair enough, but here is the thing. In Eclipse I have both and I can switch between them on a project basis. But if I use the console instead if the PATH variable has only java 8 would it be a problem?
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So long as you're only using the console to run the app then no.
If the PATH has 8 on it then it will run apps compiled with Java 7 with no problem.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!