java-7

Wrap long words in JTextPane (Java 7)

懵懂的女人 提交于 2019-11-29 01:24:56
In all versions of Java up to 6, the default behaviour of a JTextPane put inside a JScrollPane was: wrap lines at word boundaries if possible. If not, then wrap them anyway. In JDK 7, the default behaviour seems to be: wrap lines at word boundaries if possible. If not, just expand the width of the JTextPane (never wrap long words). It is easy to reproduce this, here is a SSCCE: public class WrappingTest extends JFrame { public static void main ( String[] args ) { new WrappingTest(); } public WrappingTest () { setSize(200,200); getContentPane().setLayout(new BorderLayout()); JTextPane jtp = new

Get files in a directory sorted by last modified? [duplicate]

可紊 提交于 2019-11-29 01:23:53
This question already has an answer here: Best way to list files in Java, sorted by Date Modified? 16 answers In Java 7 with the new I/O APIs, is there an easy way to list a directory's content by last modified date? Basically I only need to get the file the wasn't modified for the longest time (sort by last modified ascending, take first filename). There's no real "easy way" to do it, but it is possible: List<Path> files = new ArrayList<>(); try(DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) { for(Path p : stream) { files.add(p); } } Collections.sort(files, new Comparator<Path>

Why switch on String compiles into two switches

╄→尐↘猪︶ㄣ 提交于 2019-11-29 01:18:20
I read JVM specification on compiling switches and became interested in how switch statement on String is compiled. Here is the test method I examined (JDK1.7.0_40): static int test(String i) { switch (i) { case "a": return -100; case "45b": return 1; case "c": return 2; default: return -1; } } I expect this method to be compiled into simple lookupswitch on hashCode of string, but suddenly static int test(java.lang.String); Code: 0: aload_0 1: astore_1 2: iconst_m1 3: istore_2 4: aload_1 5: invokevirtual #6 // Method java/lang/String.hashCode:()I 8: lookupswitch { // 3 97: 44 99: 72 51713: 58

Cobertura & Java 7 support

北城以北 提交于 2019-11-28 22:37:40
Any ideas when cobertura will support java 7? Found http://sourceforge.net/tracker/index.php?func=detail&aid=3295711&group_id=130558&atid=720018 We preferred cobertura over emma and other code coverage tools and looks like we have to redo all those again, now that none of them support java 7 yet. Thanks Cobertura 2.0.3 supports Java 7, the cobertura-maven-plugin version 2.6 which uses this version has been just released T.K. I was able to get it to work by adding the following argument: -XX:-UseSplitVerifier I got it from here . I think the answer is: it won't. There is discussion on the

Programming Java 7 in Eclipse

不羁岁月 提交于 2019-11-28 22:17:58
I installed JDK 7 and Eclipse 3.6M6 . Then, I added JRE 7 as a new JRE execution environment in Eclipse, and set the compiler compliance level to Java 7. I can compile the following piece of code through command line using the javac that comes with JDK 7. import java.util.HashMap; import java.util.Map; public class Try { public static void main(String[] args) { Map<Integer, String> map = new HashMap<>(); } } But, Eclipse gives the following error messages. Incorrect number of arguments for type HashMap; it cannot be parameterized with arguments Try.java /TryJava7/src line 7 Java Problem Syntax

How to access a sub-file/folder in Java 7 java.nio.file.Path?

早过忘川 提交于 2019-11-28 22:16:44
Java 7 introduced java.nio.file.Path as a possible replacement for java.io.File. With File, when I access a file under a specific, I would do: File parent = new File("c:\\tmp"); File child = new File(parent, "child"); // this accesses c:\tmp\child What's the way to do this with Path? I supposed this will work: Path parent = Paths.get("c:\\tmp"); Path child = Paths.get(parent.toString(), "child"); But calling parent.toString() seems ugly. Is there a better way? Use the resolve method on Path . There are two methods with this name. One takes a relative Path and the other a String . It uses the

specified JRE installation does not exist

落花浮王杯 提交于 2019-11-28 22:07:23
问题 I'm trying to launch a server on my tomcat 7 on my eclipse indigo EE and I get the following error: "'starting Tomcat v7.0 server at localhost' has encountered a problem. The specified JRE installation does not exist" I checked the build path configuration and on the libraries section I have the JDK7 as JRE System Libraray and when I check "Installed JREs..." the correct path is there - "C:\Program Files\Java\jdk1.7.0_01". What else can be done? Many thanks. p.s. - I'm also using maven 3.0.3

javax.net.ssl.SSLHandshakeException: handshake_failure when using JMeter with SSL (JDK8)

…衆ロ難τιáo~ 提交于 2019-11-28 22:04:19
I am writing a JMeter test plan to connect to SSL port (Tomcat Connector). I receive a SSLHandshakeException (handshake_failure) when connecting to SSL port using any of the three JMeter SSL client implementations (HttpClient4, HttpClient3.1, Java) on JDK8 (1.8.0_51). If I use JDK7 (1.7.0_75) - everything works as expected. Client JDK: HotSpot 1.8.0_51 Client OS: Mac OSX 10.10.2 JMeter version: 2.13 Server: Tomcat 7.0.63 (latest) Server SSL CipherSuite: RC4-SHA Server SSL Protocol: all Server Java: OpenJDK 1.7.0_79 Here are some things I have already tried: (1) I tried replacing the JCE

Java Web Start broken since JDK 1.7

心已入冬 提交于 2019-11-28 21:50:05
HERES THE ANSWER: It appears (through our testing) that Java 7 Web Start requires you to host your resources on a server using an SSL certificate. Your cert does NOT have to be signed, but unsigned certs will prompt the client with a trust message that they can ignore. See the below answer for more details We have an internal application which we have been using for many years now. In order to make maintenance easier for this application we have not provided an installable version of the application to our employees, we simply give them a link to a .jnlp and use JWS to launch it on their box.

intellij feature (…) not supported at this language level. I can't compile

倖福魔咒の 提交于 2019-11-28 21:18:58
IntelliJ is showing me this error I just built my new computer and none of my java stuff is working... My regular Intellij was working when I first tried it, but my android studio would't install because it couldn't find the path to the jdk. Here is the question that I asked about that. Since that wasn't working, I had to reinstall java multiple times, and now my IntelliJ isn't working. Here is a picture of the error (I am getting an error that is telling me the for-each loops aren't supported at this language level). I have tried to install the JDK on my D: drive and that didn't work. I am