java-7

No com.sun.tools.javac in JDK7

不打扰是莪最后的温柔 提交于 2019-11-29 18:30:08
问题 I'm using JDK7 and Eclipse Indiago in Windows 7 64-bit. I set environment variable JAVA_HOME to F:\JDK7 and add %JAVA_HOME%\bin in path. It's my sample code: com.sun.tools.javac.Main m1 = new com.sun.tools.javac.Main(); m1.compile(source); Error I get: Type com.sun.tools cannot be resolved to a type Why there is no com.sun.tools ? What's the problem ? 回答1: It looks like you are using Eclipse. By default Eclipse only imports JRE jars, not the ones from the JDK. Solution 1: Go to Eclipse

java.lang.NoClassDefFoundError: sun/swing/plaf/synth/SynthUI

爷,独闯天下 提交于 2019-11-29 18:25:57
I am using Seaglass Look and Feel for my Java Swings code. But I keep getting this error. Exception in thread "main" java.lang.NoClassDefFoundError: sun/swing/plaf/synth/SynthUI at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader

Java OutOfMemory exception: mmap error on loading zip file

陌路散爱 提交于 2019-11-29 17:57:52
问题 I run my app on production env (rhel 5.2 x64, oracle jre 1.7_05, tomcat 7.0.28) with JVM arguments: -Xms8192m -Xmx8192m -XX:MaxPermSize=1024m -Doracle.net.tns_admin=/var/ora_net -XX:ReservedCodeCacheSize=512m -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -XX:+UseStringCache -XX:+OptimizeStringConcat -XX:+UseCompressedOops -XX:+UseG1GC -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9026 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate

How do I use directory globbing in JDK7

只谈情不闲聊 提交于 2019-11-29 16:39:24
问题 I have been trying to use the new globbing feature in JDK7, starting from the documentation and examples I can get globs such as "glob:*.dat" to work with the Files.walkFileTree(startingDir, finder); example but I have been unable to get the "**" syntax working. I would like to be able to create something like: matcher = FileSystems.getDefault().getPathMatcher("glob:" + "foo/**/bar/*.dat"); and would be grateful for a simple example. I am using Windows 7. UPDATE: @Oleg and @JBNizet make it

Java 7 - Precise rethrow with a final Exception

依然范特西╮ 提交于 2019-11-29 16:26:04
问题 In previous versions of java, rethrowing an exception was treated as throwing the type of the catch parameter. For example: public static void test() throws Exception{ DateFormat df = new SimpleDateFormat("yyyyMMdd"); try { df.parse("x20110731"); new FileReader("file.txt").read(); } catch (Exception e) { System.out.println("Caught exception: " + e.getMessage()); throw e; } } In Java 7, you can be more precise about the exception being thrown, if you declare the exception final : //(doesn't

The correct way to use FileVisitor in java

匆匆过客 提交于 2019-11-29 15:21:58
问题 I am trying to step through an entire path and its single layer of sub directories. For each file, I need to read five data fields and output them to a delimited text file. I'm able to read from a single text file and validate my output on screen; after that I'm stuck. I cannot seem to to find the right parameters for FileVisit. Some specific questions are comments in my code posted below. And although I'm no nearly that far yes, I'd like to get some idea for writing to an output file, namely

Java AppBundler application pointing to JRE defined by JAVA_HOME

故事扮演 提交于 2019-11-29 15:09:04
问题 I have been using Java Application Bundler to pack a Java application as .app. I have managed to run the application if I pack the JRE7 inside of the .app bundle. Is it possible to configure .app (in Info.plist) to point to the JRE defined by JAVA_HOME environment variable? If I do that, I am getting "Unable to load Java Runtime Environment"! I have tried to configure the JAVA_HOME in different ways, but with no success! Can anyone provide any help or suggestion? 回答1: appbundler applications

TLS 1.2 was supported in Java 8 but not in Java 7

ぐ巨炮叔叔 提交于 2019-11-29 15:04:10
When I tried to connect a URL (one of vendors URL which supports TLS 1.2 and worked fine previously with Java 7) by using Java 7, I found bellow Exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) at sun.security.ssl.Alerts.getSSLException(Alerts.java:154) at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1943) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1059) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1294) at sun.security.ssl

Java 7: ThreadLocalRandom generating the same random numbers

自作多情 提交于 2019-11-29 11:58:20
问题 I'm trying out Java 7's ThreadLocalRandom and see that it is generating exactly the same random numbers across multiple threads. Here is my code, in which I create 5 threads and each thread prints out 5 random numbers: //5 threads for(int i = 0; i < 5 ; i++) { final Thread thread = new Thread() { @Override public void run() { System.out.print(Thread.currentThread().getName()+":"); //each thread prints 5 random numbers for(int j = 0 ; j < 5; j++) { final int random = ThreadLocalRandom.current(

Is the OpenJDK JVM the same as the Oracle Java SE JVM?

烈酒焚心 提交于 2019-11-29 11:20:33
问题 I understand that the Oracle Java SE contains closed source extensions and tools that are not part of the OpenJDK however is the Oracle Java SE JVM identical to the OpenJDK JVM or does Oracle make changes to the OpenJDK JVM before releasing it as a Java SE JVM? Update 1: I found some info from the JDK7 updates projects: http://openjdk.java.net/projects/jdk7u/qanda.html Will the 7 Update Project receive security fixes from Oracle? Yes. As with OpenJDK 6, security fixes are first kept