java-7

how to make database configuration configurable of persistance.xml file through database.properties file

感情迁移 提交于 2019-12-02 18:41:17
问题 I would like to get confirmation on the query "Is there any way to make database configurations configuration through database.properties using in persistance.xml ". Is the below possible? My following configuration works absolutely fine, <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns

How to get CPU, RAM and Network-Usage of a Java7 App

被刻印的时光 ゝ 提交于 2019-12-02 18:35:56
I found this older article how-to-monitor-the-computers-cpu-memory-and-disk-usage-in-java and wated to ask, if there is something new in java 7. I want to get the current CPU-, RAM- and netzwork-Usage of my App periodically. It has to work for linux (mac) and windows. The data must not be extremely detailed, 3 values would be enough (cpu: 10%, Ram 4%, Network 40%). Would be cool if the data is just for the app and not the whole os-system, however this would work, too. Thank's for help answering my own question ;P some code i have written... NetworkData: public class NetworkData { static Map

apt-get installing oracle java 7 stopped working

隐身守侯 提交于 2019-12-02 18:20:01
Recently apt-get install -y oracle-java7-installer stopped working. I know in their roadmap, I think the public version is no longer supported, but it's been working all the way until recently. http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html Anyone have a work around for this? http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz?AuthParam=1495560077_4041e14adcb5fd7e68827ab0e15dc3b1 Connecting to download.oracle.com (download.oracle.com)|96.6.45.99|:80... connected. HTTP request sent, awaiting response... 404 Not Found 2017-05-23 10

Java 7 way to write a file

痴心易碎 提交于 2019-12-02 18:11:49
问题 I have managed to read a file by Files.copy(Paths.get(file.toURI()), System.out); How do I write a sequence of characters to a file? I see no effect from Files.copy(new ByteArrayInputStream(content.getBytes()), Paths.get(file.getName())) and it looks ugly. 回答1: I have succeeded this way Files.write(Paths.get(file.getName()), content.getBytes()); 来源: https://stackoverflow.com/questions/19932567/java-7-way-to-write-a-file

Compiling java 7 for java 6 with Eclipse

别说谁变了你拦得住时间么 提交于 2019-12-02 14:58:23
问题 I need to compile a project for Java 6 to use with java 6 or 7 (I can't upgrade all of the computers in my life). I've been searching all over and found somewhat helpful stuff, but I'm rather new to java - I don't understand much of how to use the presented alternatives (ant-build, Maven, javac). My program does not use any API methods that are not available in Java 6, but it does use the API of another external .JAR (it is a basic plugin for an example program) Is there a simple way to do

SocketChannel read() behaviour - short reads

霸气de小男生 提交于 2019-12-02 14:33:06
问题 The ServerSocketChannel is used this way: ServerSocketChannel srv = ServerSocketChannel.open(); srv.socket().bind(new java.net.InetSocketAddress(8112)); SocketChannel client = srv.accept(); When a connection is received, data is read this way: ByteBuffer data = ByteBuffer.allocate(2000); data.order(ByteOrder.LITTLE_ENDIAN); client.read(data); logger.debug("Position: {} bytes read!", data.position()); It prints: Position: 16 bytes read! Why isn't the SocketChannel blocking until the buffer is

Java: int array initializes with nonzero elements

匆匆过客 提交于 2019-12-02 14:05:29
According to the JLS, an int array should be filled by zeros just after initialization. However, I am faced with a situation where it is not. Such a behavior occurs first in JDK 7u4 and also occurs in all later updates (I use 64-bit implementation). The following code throws exception: public static void main(String[] args) { int[] a; int n = 0; for (int i = 0; i < 100000000; ++i) { a = new int[10]; for (int f : a) if (f != 0) throw new RuntimeException("Array just after allocation: "+ Arrays.toString(a)); Arrays.fill(a, 0); for (int j = 0; j < a.length; ++j) a[j] = (n - j)*i; for (int f : a)

Java 7, color of button text when using HTML formatted labels

旧街凉风 提交于 2019-12-02 12:47:06
问题 I have a custom UI for certain buttons, implemented by subclassing MetalButtonUI. The buttons use HTML-formatted labels. This is a requirement for me, I need to support multiline button labels. For some reason, when my application runs on Java 7 (scientifically update 4, the most current) the text color when the button is disabled is now grey. This does not happen when running on Java 4 or 6. In the HTML for the button label, I can set the font color by using <font color=..> However this

Compiling java 7 for java 6 with Eclipse

非 Y 不嫁゛ 提交于 2019-12-02 12:06:09
I need to compile a project for Java 6 to use with java 6 or 7 (I can't upgrade all of the computers in my life). I've been searching all over and found somewhat helpful stuff , but I'm rather new to java - I don't understand much of how to use the presented alternatives (ant-build, Maven, javac). My program does not use any API methods that are not available in Java 6, but it does use the API of another external .JAR (it is a basic plugin for an example program) Is there a simple way to do this with Eclipse's Export function, or do I need to use some other program/method? If I need to use

Java 7 way to write a file

只愿长相守 提交于 2019-12-02 09:55:01
I have managed to read a file by Files.copy(Paths.get(file.toURI()), System.out); How do I write a sequence of characters to a file? I see no effect from Files.copy(new ByteArrayInputStream(content.getBytes()), Paths.get(file.getName())) and it looks ugly. I have succeeded this way Files.write(Paths.get(file.getName()), content.getBytes()); 来源: https://stackoverflow.com/questions/19932567/java-7-way-to-write-a-file