Other Cannot find java.time.LocalDateTime

Hello,

I'm trying to compile a program in Java in FreeBSD but it doesn't find java.time.LocalDateTime and java.time.DateTimeFormatter.

I installed the last version from OpenJDK and JRE available through pkg but it didn't work. I could compile in my Mac.

How can I use this library in FreeBSD?
 
I have no problem compiling and running the following:
Code:
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class testTime {
  public static void main(String args[]) {
    LocalDateTime currTime = LocalDateTime.now();
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy MM dd");
    System.out.println(currTime.format(formatter));
  }
}

What error are you getting?
 
There are a bunch of errors. Here follow some of them. There are others but all them says the same thing. Sorry putting the errors in a picture, but my FreeBSD is in a virtual machine with no easy access to my real OS.

Screen Shot 2015-07-28 at 11.27.42 PM.png
Screen Shot 2015-07-28 at 11.33.16 PM.png
 
Yes, I know and I installed jdk8 I think that my problem is that now I have both jdk7 and jdk8 on my FreeBSD. Do you know how can I let only the right one?
 
Yes, I know and I installed jdk8 I think that my problem is that now I have both jdk7 and jdk8 on my FreeBSD. Do you know how can I let only the right one?

The java command is just a shell script in /usr/local/bin/java. This shell script can be controlled by the JAVA_VERSION environmental variable to call the correct OpenJDK.

For tcsh(1):
# setenv JAVA_VERSION 1.8+
For sh(1)
# export JAVA_VERSION=1.8+

# java -version
Code:
openjdk version "1.8.0_51"

Similarly if you needed OpenJDK 7, this would be as simple as setting "1.7".
 
Back
Top