java-10

var keyword not reconized in JDK 10

☆樱花仙子☆ 提交于 2019-12-01 11:39:37
I have installed netbeans (Apache version) with JDK 10 successfully, but can't use var keyword in my project, It keep saying cannot find symbol . Any help would be appreciated. To use the var keyword with JDK 10 in NetBeans: Ensure that you are running the latest version of Apache NetBeans . In NetBeans add JDK 10 as a Java platform ( Tools > Java Platforms > Add Plaform... ). It is not necessary to make JDK 10 the default. Create a simple Java application ( File > New Project... > Java > Java Application ) and declare a var variable (e.g. var v = 7; ) within the main() method. Select the

How to upgrade Hibernate from version 4.3 to 5.2 for migration to JDK 10?

为君一笑 提交于 2019-12-01 10:33:45
问题 Since JDK8 Oracle announced that no longer support, I am required to upgrade the current JDK to JDK10 . After study, the current hibernate is also required to upgrade from hibernate 4 to hibernate 5 , in order to run at JDK 10. However, there are some hibernate related libraries, should I also upgrade, if yes, which version that is suitable? Here is an extract of my current pom.xml : <properties> <hibernate.version>4.3.11.Final</hibernate.version> <java-version>1.7</java-version> <project

The import java.awt cannot be resolved

白昼怎懂夜的黑 提交于 2019-12-01 07:38:05
问题 I have installed the Eclipse [Version: Photon Release (4.8.0)] and JDK 10 on a MacBookPro with macOS 10.13.5 When I write in my code: import java.awt.*; I get the error: The import java.awt cannot be resolved Is the java.awt included in JDK 10 ? If yes where is and how can I make visible to Eclipse? If no how can I add java.awt? 回答1: Is the java.awt included in JDK 10? Ye, the package does exist. The Java10 API docs do confirm the same as well. If yes where is and how can I make visible to

Java: DateTimeFormatter fail to parse time string when seconds and milliseconds are all 0s?

老子叫甜甜 提交于 2019-12-01 07:18:46
问题 Basically, I am using the following code to parse string as LocalDateTime, which works fine most of the time. DateTimeFormatter dtformatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"); However, I encounter cases where the seconds and millseconds are 00000 and this is when the parser fails and print a LocalDateTime 2018-03-01T09:16 instead of 2018-03-01T09:16:00.000 . System.out.println(LocalDateTime.parse("20180301091600000",dtformatter)); (Note that in my code, I have to parse string

Java 10 (and following) on 32-Bit systems

非 Y 不嫁゛ 提交于 2019-12-01 03:45:49
As far as I know there are no plans from oracle to ship java for 32 Bit - but maybe I misunderstand the situation. If I'm correct - what do we all do if we need to support 32-Bit libraries (dlls)? And whats about 32 Bit OSes out there? Currently this seems to be a huge impact in the future but as I said - maybe I'm wrong. Fact is that we can't download a Java 10 runtime in 32 Bit as there are only 64 Bit Download-Links. Oracle is not the only party building and distributing OpenJDK. For example Azul maintains, but does not certify as TCK-compliant, 32bit windows builds as part of their Zulu

Unrecognized VM option 'UseParNewGC' , Error: Could not create the Java Virtual Machine

Deadly 提交于 2019-12-01 02:53:58
I am trying to start a server using jre 10.0.1 64 bit. There is an obvious change in the settings for the JVM in windows start batch files. With the setting of -XX:+UseParNewGC as the reference point of the error what would this need to be changed to in order to get a JVM server start with java 10 versus the java 8 settings I have shown? The line of code causing the error reference is: set JAVA_PARAMETERS=-XX:+UseParNewGC -XX:+CMSIncrementalPacing -XX:+CMSClassUnloadingEnabled -XX:ParallelGCThreads=2 -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 Peter Lawrey This collectors was deprecated in

“array initializer needs an explicit target-type” - why?

て烟熏妆下的殇ゞ 提交于 2019-12-01 02:42:18
Following JEP 286: Local-Variable Type Inference description I am wondering, what the reason is for introducing such a restriction, as: Main.java:199: error: cannot infer type for local variable k var k = { 1 , 2 }; ^ (array initializer needs an explicit target-type) So for me logically it should be: var k = {1, 2}; // Infers int[] var l = {1, 2L, 3}; // Infers long[] Because Java compiler can already infer properly the type of an array: void decide() { arr(1, 2, 3); // call void arr(int ...arr) arr(1, 2L, 3); // call void arr(long ...arr) } void arr(int ...arr) { } void arr(long ...arr) { }

Different behaviour of same statement while executing on JShell

心不动则不痛 提交于 2019-11-30 23:00:03
I was working on a problem to store reference of two classes within each other For Example: class A { B b; A(B b){ this.b = b;} } class B { A a; B(A a){ this.a = a;} } public static void main(String...s){ A a = new A(new B(null)); a.b.a = a; } Now if instead of above initialisation, if I use below statement: A a = new A(new B(a)); I got below error which is quite obvious: Main.java:19: error: variable a might not have been initialised A a = new A(new B(a)); But if I try the same on JShell, it works just fine (Just to be extra sure that variable a has never been initialized, I checked for

Unrecognized VM option 'UseParNewGC' , Error: Could not create the Java Virtual Machine

跟風遠走 提交于 2019-11-30 22:25:09
问题 I am trying to start a server using jre 10.0.1 64 bit. There is an obvious change in the settings for the JVM in windows start batch files. With the setting of -XX:+UseParNewGC as the reference point of the error what would this need to be changed to in order to get a JVM server start with java 10 versus the java 8 settings I have shown? The line of code causing the error reference is: set JAVA_PARAMETERS=-XX:+UseParNewGC -XX:+CMSIncrementalPacing -XX:+CMSClassUnloadingEnabled -XX

Can a local variable with an inferred type be reassigned to a different type?

て烟熏妆下的殇ゞ 提交于 2019-11-30 22:05:35
I remember reading somewhere that local variables with inferred types can be reassigned with values of the same type, which would make sense. var x = 5; x = 1; // Should compile, no? However, I'm curious what would happen if you were to reassign x to an object of a different type. Would something like this still compile? var x = 5; x = new Scanner(System.in); // What happens? I'm currently not able to install an early release of JDK 10, and did not want to wait until tomorrow to find out. Would not compile, throws "incompatible types: Scanner cannot be converted to int" . Local variable type