java-8

Jetty 9 + Java > 8u74 always allocates maximum (-Xmx) memory on Linux?

烈酒焚心 提交于 2019-12-23 16:32:55
问题 If I start a Java application using jre 8u74 on Linux using -Xmx512m the memory is not allocated immediately, the memory is allocated if Java needs it. So it can stay below the 512 MB limit if not necessary. This is what I would expect. On Java 8u111 I get another behavior, the 512 MB of memory is always allocated immediately to the process even if Java does not need it. This is annoying since this memory cannot be used by other processes, even if Java does not need it. I looked trhough the

Does Java8 supports operator overloading

懵懂的女人 提交于 2019-12-23 16:24:31
问题 So I'm interested is there a way to overload operator in Java 8? Is there exist something like void operator(){ } in C++ ? 回答1: No, there is no operator overloading in Java 8. If you don't know it yet, you could have a look at Xtend which is a JVM language that compiles to pure Java. It supports operator overloading and a lot more features while it's still has a static type system. (And, of course, there is Groovy, Scala, and other JVM scripting languages which support operator overloading as

Using Nashorn in Java?

十年热恋 提交于 2019-12-23 15:23:16
问题 I'm reading about new Java 8 features and came to know it comes with Nashorn (Javascript engine). Can someone explain me why would/should I use a Javascript engine inside Java. What programming problems it would solve ? any examples Thanks, Ravi 回答1: Simply, it would allow you to create standalone JavaScript programs and allow embedding JavaScript in Java. Java must be compiled into what is known as a "machine language" before it can be run. JavaScript is text-based and interpreted, and is

Read X lines at a time from a text file using Java Streams?

做~自己de王妃 提交于 2019-12-23 13:22:14
问题 I have a "plain old text file" where lines end with a new line character. For arbitrary reasons I need to read and parse this text file 4 (X for generality) lines at a time. I'd like to use Java streams for this task and I know I can turn the file into a stream like so: try (Stream<String> stream = Files.lines(Paths.get("file.txt""))) { stream.forEach(System.out::println); } catch (IOException e) { e.printStackTrace(); } But how can I use Java's Stream API to "bunch" the file into groups of 4

Glassfish eclipse Plugin with jdk 8

本小妞迷上赌 提交于 2019-12-23 12:33:39
问题 Im trying to launch glassfish-4 using glassfish-eclipse-plugin. Unfortunately it does not seem to recognize the JDK-8 Release candidate i just installed (The "Finish" button stays disabled). Finish button will be enabled if i select a java 7 jdk Is there any options to work around this? 回答1: Now Lambda support works "out-of-the-box" if using below combination of software Oracle JDK 8 http://www.oracle.com/technetwork/java/javase/downloads/index.html Glassfish from 4.01 branch http://dlc.sun

Unsupported major.minor version 52.0 Error [duplicate]

时间秒杀一切 提交于 2019-12-23 12:23:07
问题 This question already has answers here : Unsupported major.minor version 52.0 [duplicate] (26 answers) Closed 4 years ago . I have codes compiled on JDK 1.8. I created war file and deployed it on Tomcat8 in an Ubuntu server running JRE 1.8. I have this error when opening the main page: java.lang.UnsupportedClassVersionError: com/dash/io/web/bind/HomeCtrl : Unsupported major.minor version 52.0 $ java -versionjava version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java

How to catch and process JavaFX TouchEvent in Swing Application?

不想你离开。 提交于 2019-12-23 12:05:18
问题 I developed a Swing application in which I now need to implement a customized multi-touch gesture. After some research, the easiest approach seemes to be the use of JavaFX, because it can be embedded in Swing and provides events for every finger on the touch screen seperately. I then tried to implement touch handling according to the following examples: http://docs.oracle.com/javafx/2/swing/swing-fx-interoperability.htm http://docs.oracle.com/javafx/2/events/touch_events.htm I decided to

How to Run Annotation Processor without compiling sources using javac (Java 8 can't use Apt)

拟墨画扇 提交于 2019-12-23 11:52:35
问题 How can i Run Annotation Processor without compiling sources using javac (Java 8 can't use Apt)? Is there any parameter for javac that could run only annotation processing without compiling all files? What i want to do by javac: Just find annotated elements and process them using defined annotation processor using -processor flag do not compile any source that doesn't have any annotation Because i want do this on Java 8 it's impossible to use Apt for this task? Or maybe it is? 回答1: The apt

Issue about java 8 backward compatibility: new methods in JDK

扶醉桌前 提交于 2019-12-23 11:48:14
问题 Simple question. In Java 8 we have huge number of new methods in JDK classes. Say we have created such class, using Java 7 (or Java 6): class MyArrayList<E> extends ArrayList<E> { public void sort(Comparator<E> c) { // some sort } } This is quite reasonable implementation. Now we try to compile it with Java 8 and receive expectable compile error: error: name clash: sort(Comparator<E#1>) in MyArrayList and sort(Comparator<? super E#2>) in ArrayList have the same erasure, yet neither overrides

Spring boot 2 Converting Duration java 8 application.properties

自闭症网瘾萝莉.ら 提交于 2019-12-23 10:53:18
问题 I need to define Duration value (spring.redis.timeout) by application.properties. I was trying to use one point defined in Spring boot documentation : Spring Boot has dedicated support for expressing durations . If you expose a java.time.Duration property, the following formats in application properties are available: A regular long representation (using milliseconds as the default unit unless a @DurationUnit has been specified) The standard ISO-8601 format used by java.util.Duration A more