java-7

Access non-public (java-native) classes from JDK (7)

可紊 提交于 2020-01-06 14:16:19
问题 I want to use the method MethodHandleNatives.getTargetMethod(MethodHandle)AccessibleObject. The class MethodHandleNatives is not public. So does anybody know how I can do that? I know that its possible to access private methods and fields via reflections, so I am asking, if this is also possible. Thanks. 回答1: I have found a solution. It is not straight forward but it works =) MethodHandle mh; // a MethodHandle Object Class<?> mhn; try { mhn = Class.forName("java.lang.invoke

Why does Java compiler give “error: cannot find symbol” for LinkedList descendingIterator in the following code?

余生长醉 提交于 2020-01-06 08:05:21
问题 Why does this code: import java.util.*; class Playground { public static void main(String[ ] args) { List<Integer> l = new LinkedList<>(); Iterator<Integer> i = l.descendingIterator(); } } Generate this compiler error ./Playground/Playground.java:5: error: cannot find symbol Iterator<Integer> i = l.descendingIterator(); ^ symbol: method descendingIterator() location: variable l of type List<Integer> 1 error Here is the relevant JavaDocs API Running Java 7.. In case that is issue. Thought it

Add cipher suite TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 to Java 7

末鹿安然 提交于 2020-01-05 11:37:49
问题 I'd like to use TLSv1.2 with TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 in Java 7. I've added -Ddeployment.security.TLSv1.2=true to the VM arguments and I'd like to know how to add the cipher suite mentioned above. 回答1: Hints provided by @ dave_thompson_085. Java 7 JSSE (the SSL/TLS provider) does not implement GCM ciphersuites, only Java 8 does. A thirdparty provider like BouncyCastle might. Also remember all Oracle/Sun JREs support AES-256 suites (and more-than-128-bit symmetric encryption

Add cipher suite TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 to Java 7

余生长醉 提交于 2020-01-05 11:37:47
问题 I'd like to use TLSv1.2 with TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 in Java 7. I've added -Ddeployment.security.TLSv1.2=true to the VM arguments and I'd like to know how to add the cipher suite mentioned above. 回答1: Hints provided by @ dave_thompson_085. Java 7 JSSE (the SSL/TLS provider) does not implement GCM ciphersuites, only Java 8 does. A thirdparty provider like BouncyCastle might. Also remember all Oracle/Sun JREs support AES-256 suites (and more-than-128-bit symmetric encryption

Can not permit Java encoding names in Tomcat6

二次信任 提交于 2020-01-05 10:32:00
问题 On two supposedly identical machines, I am having two different startup results for Tomcat 6.0.24. I am using Java version 1.7_09 on both, yet get wildly different results. The problem is that I apparently can not use Java encoding names in Tomcat6, as stated below: May 6, 2013 4:01:43 p.m. org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr

Choose return class type based on parameter with Java 7

ε祈祈猫儿з 提交于 2020-01-05 00:46:26
问题 I am looking for whether is possible or not to make this in Java 7: Now, I have this functions like this in several services, which third parameter will be diffent in each one: final RequestDTO1 requestDTO = (RequestDTO1) getDTO(param, RequestDTO1.class); final RequestDTO2 requestDTO = (RequestDTO2) getDTO(param, RequestDTO2.class); final RequestDTO3 requestDTO = (RequestDTO3) getDTO(param, RequestDTO3.class); This is the getDTO signature: protected Object getMessage(Object param, Class clazz

Choose return class type based on parameter with Java 7

倖福魔咒の 提交于 2020-01-05 00:46:11
问题 I am looking for whether is possible or not to make this in Java 7: Now, I have this functions like this in several services, which third parameter will be diffent in each one: final RequestDTO1 requestDTO = (RequestDTO1) getDTO(param, RequestDTO1.class); final RequestDTO2 requestDTO = (RequestDTO2) getDTO(param, RequestDTO2.class); final RequestDTO3 requestDTO = (RequestDTO3) getDTO(param, RequestDTO3.class); This is the getDTO signature: protected Object getMessage(Object param, Class clazz

How to set the PATH environment variable for JVM

眉间皱痕 提交于 2020-01-04 23:02:59
问题 I am trying to run executables which are installed on my system with the Java 7 ProcessBuilder. I noticed that the environment variable PATH, which is available via System.getenv("PATH"); does not include my own, custom set path. It returns this: /usr/bin:/bin:/usr/sbin:/sbin My path looks like this: /Users/saschaf/.bin:/Users/saschaf/Entwicklung/spring-roo-1.2.4.RELEASE/bin:/usr/local/opt/ruby/bin:/usr/local/bin:/Users/saschaf/Entwicklung/android-sdk-macosx/tools:/Users/saschaf/Entwicklung

Wondering whether I need to installll JDK 1.6 & 1.7 together?

不羁岁月 提交于 2020-01-04 05:34:08
问题 Can I use JDK 1.7 to compile the code written in JDK 1.6? Is Java strict downward compatible? Do I need to keep JDK 1.6 and JDK 1.7 together in the same machine? 回答1: Can I use JDK 1.7 to compile the code written in JDK 1.6? Yes. Is Java strict downward compatible? If the cross-compilation options are specified when compiling. Those are most notably: -source -target -bootclasspath - which requires an rt.jar of the JRE (not JDK) being targeted 回答2: Can I use JDK 1.7 to compile the code

How to use Try-with-resources with if statement?

余生长醉 提交于 2020-01-04 04:16:25
问题 I have the simple code: try (FileReader file = new FileReader(messageFilePath); BufferedReader reader = new BufferedReader(file)) { String line; while ((line = reader.readLine()) != null) { //// } } I want to write something like that: FileReader file = null; ///..... try(file = (file == null ? new FileReader(messageFilePath) : file); BufferedReader reader = new BufferedReader(file)) { String line; while ((line = reader.readLine()) != null) { //// } } It is allows me to reuse FileReader . Is