Menu
  • HOME
  • TAGS

What am I doing wrong with passing Rectangle to setContent in javafx 2?

java,netbeans,javafx,javafx-2,java-7

import javafx.scene.shape.Rectangle; Its unlikely anything other than a wrong import is causing this....

porting Java 8 code to Java 7

spring,java-7,java-8

You can do it in such way: protected UserDetailsService userDetailsService() { return new UserDetailsService() { @Override UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { User u = crmService.findUserByUsername(username); return new org.springframework.security.core.userdetails.User( u.getUsername(), u.getPassword(), u.isEnabled(), u.isEnabled(), u.isEnabled(), u.isEnabled(), AuthorityUtils.createAuthorityList("USER", "write")); } } } But definitely you should think about extracting it to normal...

Java 7: IF condition triggered when false

java,if-statement,java-7

It can only be a problem using threads. The update of the values of a shared variable can be delayed. Make limit volatile or so. It is basically a threading issue, a search on java volatile will point further. Rather silly but threads can have stale values of some variable...

Performance regression when migrating from jdk1.7.0_25 to jdk1.7.0_40

java,performance,java-7

It looks like the problem is due to work done in JDK-7133857, in which java.lang.Math.pow() and java.lang.Math.exp() were intrinsified and calculated using x87. These methods are used extensively (!) in the profiled application and hence their considerable effect. JDK-8029302 describes and fixes the issue for power of 2 inputs; and...

Underscore between digits [duplicate]

java,int,java-7

See Underscores in Numeric Literals: In Java SE 7 and later, any number of underscore characters (_) can appear anywhere between digits in a numerical literal. This feature enables you, for example, to separate groups of digits in numeric literals, which can improve the readability of your code. You didn't...

Lock+HasMap or ConcurrentHashMap in my case?

java,concurrency,thread-safety,java-7,concurrenthashmap

So you have two separate atomic instructions which need to be synchronized with. Putting a new queue into the Map Putting an object into the Queue Here are my suggestions. Continue to use a ConcurrentHashMap. You still need to put into the map and you may as well do it...

Creating a Generic Method to Run Specific Methods as Parameters

java,java-7

Why not use an interface for this problem made for interfaces! interface PixelLogic { public int doOperation(); } class BlurLogic implements PixelLogic { @Override public int doOperation() { return // some calculated value } } class SomeClass { public void runPixelOperation(PixelLogic logic) { for(int i = 0; i < height;...

No compiler error about incompatible casts

java,generics,java-7,classcastexception

JDK is correct. The declaration promises to return ANY datasource, if it doesnt match there will be only a runtime error. Compiler may show some serious warnings but should compile it. The original developer of your snippet probably intended to avoid an explicit cast on each call. Different ways on...

Comperator caused “Comparison method violates its general contract!” - 1300 items sort

sorting,java-7

Does your collection contain null? If so, there is one problem with your comparator: It always returns 0 for null, so null is considered equal to everything. As a result for A > B (premise), you will also have A == null and null == B so by transitivity A...

Java ternary operator influence on generics type inference

java,generics,compiler-errors,java-7

Compiles for me fine in java 8. Earlier versions of Java might need more help return retval == null ? Collections.<String>emptyList() : retval; should work. EDIT This is due to improvements in Java 8 type inference as explained here http://openjdk.java.net/jeps/101 And here's a blog with the highlights: http://blog.jooq.org/2013/11/25/a-lesser-known-java-8-feature-generalized-target-type-inference/...

mvn compilation error due to Java version

java,maven,build,java-7

You can add something like this right into your POM: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.2</version> <configuration> <source>${jdk.version}</source> <target>${jdk.version}</target> </configuration> </plugin> You can find more information on the official Maven Compiler plugin page...

Java 7 Checked exception rules

java,java-7,unhandled-exception

In the first case, runnable.run does not throw any checked Exception, so your try/catch and rethrow are not inferred to throw anything checked, hence it compiles In your second case, runnable.call() throws Exception and is handled, but then rethrown. In order to fix the compilation in this case, you...

Getting UnsupportedClassVersionError in Eclipse JPA project which does not make sense

java,eclipse,jpa,java-7,jdk1.6

This means that some plugin you are using was built using java 1.7 and it would require 1.7 or greater jre. Check the plugin which contains the class mentioned in the stack trace.

RandomAccessFile Vs NIO Channel

java,java-7,nio,java-io,filechannel

From the specification of RandomAccessFile.getChannel(): The position of the returned channel will always be equal to this object's file-pointer offset as returned by the getFilePointer method. Changing this object's file-pointer offset, whether explicitly or by reading or writing bytes, will change the position of the channel, and vice versa. Changing...

Joining (union) of Sets inside a Set in Java

iterator,set,java-7,java-api,set-union

On the one hand you could use the new Java 8 fluent interface import static java.util.stream.Collectors.toSet; Set<Integer> myUnion = map .values() .stream() .flatMap(set -> set.stream()) .collect(toSet()); On the other hand I would suggest taking a look at Guava's SetMultimap if you can use external libraries....

How to generate date with milliseconds [duplicate]

java,java-7,java.util.date

new SimpleDateFormat("dd-MM-yyyy:HH:mm:ss.sss") You're never printing milliseconds here. Read the javadoc of SimpleDateFormat, or the answers you already got. The pattern for milliseconds is SSS, not sss. sss prints seconds. Note that even in your incorrect test, you got 10 values being printed. And that is a proof that the 10...

JavaFx Webview goes to mobile site -(using jdk 7)

java,webview,javafx,java-7,javafx-webengine

According to an comment an this question's answer. You should be able to set a user agent for your Weview with webEngine.setUserAgent(USER_AGENT_STRING). It seems to need JDK8 though. Indeed the JavaFX 2.2 javadoc doesn't contain it, though the JavaFX 8 one does. You may be able to fake something like...

JAXB mixed versions? undefined 'required' attribute

java,jaxb,jax-ws,mule,java-7

We can above this behavior , replacing in Mule CE Runtime Folder (C:\AnypointStudio\plugins\org.mule.tooling.server.3.5.0_3.5.0.201405141856\mule\lib\opt) the following jars: jaxb-api-2.1 to jaxb-api-2.2.jar jaxb-impl-2.1.9 to jaxb-impl-2.2.7.jar jaxb-xjc-2.1.9 to jaxb-xjc-2.2.7.jar Would be usefull if Mule developers replace this packages to the newest distributions....

Stanford CorpNLP returning wrong results

java-7,stanford-nlp,eclipse-3.4,lemmatization

The problem in this example is that the word painting can be the present participle of to paint or a noun and the output of the lemmatizer depends on the part-of-speech tag assigned to the original word. If you run the tagger only on the fragment painting, then there is...

Collections.sort() is not working across all members

java,sorting,java-7

Your compareTo method breaks the contract for that method in two ways. 1) Transitivity says that if x.compareTo(y) > 0 and y.compareTo(z) > 0 then x.compareTo(z) > 0. Your method breaks this because 5 > 4 and 4 > 1, but 5>1 is not one of your rules. 2) compareTo...

Why Netbeans warns me of finalize?

java,netbeans,java-7,finalize

finalize methods have the problem that they may be called at an arbitrary time by an arbitrary thread or even never at all. And like discussed in this question they may be called surprisingly early, i.e. when instance methods are still being executed, so using them to free a resource...

Collection intermediate operations library in Java7

collections,java-8,java-7,guava,apache-commons-collection

Guava As your [Guava] tag suggests, most Guava collection operations are lazy - they are applied only once needed. For example: List<String> strings = Lists.newArrayList("1", "2", "3"); List<Integer> integers = Lists.transform(strings, new Function<String, Integer>() { @Override public Integer apply(String input) { System.out.println(input); return Integer.valueOf(input); } }); This code seems to...

Reading and writing files using Java 7 nio

java,file-io,gson,java-7,nio

There is no point of using Filter if you want to read all the files from the directory. Filter is primarily designed to apply some filter criteria and read a subset of files. Both of them may not have any real difference in over all performance. If you looking to...

In java SE 7, whether all sub classes of runtimeexception and errors are unchecked exceptions?

java,java-7

The documentation is quite clear about this (links are to Java 7, although of course the current version is Java 8): Error: ..Error and its subclasses are regarded as unchecked exceptions for the purposes of compile-time checking of exceptions. (my emphasis) RuntimeException: RuntimeException and its subclasses are unchecked exceptions. (my...

Switch statement with string

java,switch-statement,java-7

"Str1" is a compile-time constant and that's why case "Str" is fine. However, the from the definition of First_String we can see that it is not a constant, because it can change it's value at any time. You can try setting it as final: public static final String First_String =...

setting and getting time from Date in java

java,date,java-7

Try this: public static Date copyTimeOnly(Date toDate, Date fromDate) { Calendar toCal = new GregorianCalendar(); toCal.setTime(toDate); Calendar fromCal = new GregorianCalendar(); fromCal.setTime(fromDate); // Copy time only toCal.set(Calendar.HOUR_OF_DAY, fromCal.get(Calendar.HOUR_OF_DAY)); toCal.set(Calendar.MINUTE, fromCal.get(Calendar.MINUTE)); toCal.set(Calendar.SECOND, fromCal.get(Calendar.SECOND)); toCal.set(Calendar.MILLISECOND, fromCal.get(Calendar.MILLISECOND)); return toCal.getTime(); } ...

Strong Reference class

java,reference,java-7,strong-references

...and extending Reference manually seems like the completely wrong direction. It's worse than that. According to the API: Because reference objects are implemented in close cooperation with the garbage collector, this class may not be subclassed directly. If you want to be able to store multiple different kinds of...

Javadoc layout changed with JDK8

java,java-8,java-7,javadoc,doclet

If you are referring to the doclet, you can turn the doclet off by adding -Xdoclint:none to the command line call to javadoc http://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html If you just want the old CSS used in Java 7 this other Stack overflow question contains the css you can use instead: JDK8: Getting back...

Print a message after Tomcat comes up

java,tomcat7,java-7,spring-4

Luiggi Mendoza pointed me in the right direction. Here's my solution. @WebListener public class Banner implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent sce) { System.out.println(System.getenv()); } @Override public void contextDestroyed(ServletContextEvent sce) { } } You need servlets 3.0 or greater to use @Weblistener....

How to create a reverse map in java?

java,java-7

Just implement it: Map<String, ArrayList<String>> getReversedMap(Map<String, ArrayList<String>> myMap){ Map<String, ArrayList<String>> result = new HashMap<>(); for(String key : myMap.keySet()){ for(String val : myMap.get(key)){ if(!result.containsKey(val)){ result.put(val, new ArrayList()); } result.get(val).add(key); } } return result; } ...

JUnit test method comparing DateTimes fails only when run from suites

java,junit,java-7,junit4

Over the process of trying to produce an MCVE and author the question, I discovered something interesting: When the test is run at the method level, note the timestamp difference of 1 millisecond. The difference is never less than that: [START: 2015-02-26T11:53:20.581-06:00, STOP: 2015-02-26T11:53:20.641-06:00, DURATION: 0.060] [START: 2015-02-26T11:53:20.582-06:00, STOP: 2015-02-26T11:53:20.642-06:00,...

Is there a safe way to download the java JDK? [closed]

java,ssl,java-7

The oracle java download site was never designed to use SSL. The site in this case is only using SSL because of the HTTPSEverywhere browser plugin that I have installed, which is forcing all Oracle domains to use HTTPS when contacted by my browser. In order to make the download...

Dozer : String-To-Date Field Level Mapping for a List

java,date,java-7,dozer

As,Dozer is not able to convert String-To-Date - At Field Level Mapping for a List. I had defined a new mapping for the List i.e., considering it as a Object I Changed the DozerMapper.xml <?xml version="1.0" encoding="UTF-8"?> <mappings xmlns="http://dozer.sourceforge.net" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://dozer.sourceforge.net http://dozer.sourceforge.net/schema/beanmapping.xsd"> <mapping date-format="MM/dd/yyyy HH:mm" map-null="true" map-empty-string="true" wildcard="true"...

Construct FrameNode with ASM api

java-7,bytecode,java-bytecode-asm,bytecode-manipulation,stackframe

Provided that your bytecode is correct, you can let asm create the frame nodes for you. I usually do it like this: ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES) { @Override protected String getCommonSuperClass(final String type1, final String type2) { // the default asm merge uses Class.forName(), this prevents that. return "java/lang/Object";...

Concatenate variable argument list

java,concatenation,java-7,varargs,variableargumentlists

There isn't a way around creating a new String[], like so: public String myMethod(String... args) { String[] concatenatedArray = new String[args.length + 1]; concatenatedArray[0] = "other string"; for (int i = 0; i < args.length; i++) { // or System.arraycopy... concatenatedArray[i + 1] = args[i]; } return myOtherMethod(concatenatedArray); } Or,...

What is the code convention for formatting try-with-resources? [closed]

java,java-7,indentation,readability,try-with-resources

There is no "right" or "wrong" when aesthetics is involved; and each organization ends up converging on its own coding style. However, it is frequent to borrow coding styles from well-known projects or organizations. One of the most-used Java code-bases is the JDK itself. After a few greps, I found...

Can't prevent text from being entered in JTextArea (in JScrollPane)

java,swing,jscrollpane,java-7,jtextarea

Remove these lines from your code fieldType.setPreferredSize(new Dimension(200, 100)); fieldType.setMaximumSize(new Dimension(200, 100)); import java.awt.CardLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton;...

How to send a string with many lines from command line

java,command-line,java-7

The problem is that im receiving '\\n' instead of '\n' so then i have different solutions One is make a script using echo -e #!/bin/bash VARIABLE=`echo -e "\n\nsomething\n\nhappens"` java -jar test.jar "$VARIABLE" another solution text = text.replace("\\n","\n"); ...

java.nio.file not working even with JDK 1.7 in Eclipse

java,eclipse,java-7

Solved it! Even after doing all the recommended things it wasn't working. Finally saw a setting in another thread that I hadn't tried till now. Project -> Properties -> Java Build Path -> Libraries -> Add Library -> JRE System Library -> Select Workspace Default (jdk 1.7*) Done. So even...

MalformatedInputException with Utility.convertByteArrayToCharArray and MessageDigest

java,java-7

Let's look at each step: byte[] hashedPassword= Utility.convertCharArrayToByteArray(password, null); The above converts the Unicode-16 characters to a byte-array using the default endcoding, probably WIN-1252 or UTF-8. Since the password contains nothing outside standard 7-bit ASCII, the result is the same for either encoding. hashedPassword = md.digest(hashedPassword); hashedPassword now refers to...

adding dragged component to JPanel on java8

java,swing,java-8,java-7,mousemotionlistener

You have to ensure that the modified Container gets revalidated and repainted afterwards, e.g. by calling the similarly named methods on it. But generally, removing and adding components while a mouse event processing is ongoing, is a bad idea. Thankfully, you don’t have to implement it that complicated. Here is...

Is it safe to run an applicaton written in Java 6 with Java 7?

java,java-7,java-6

Should it be relatively safe to "break" this check? What are the problems I could run into? Yes. I would assume that check is to prevent you from running on earlier versions (or unsupported versions). It could stop working. And, it might violate any support contracts you have. It's...

Create list of Java metaclasses that have common base class

java,java-7

Use a wildcard upper-bounded by your base class: List<Class<? extends BaseClass>> a = new ArrayList<Class<? extends BaseClass>>(); If you declare it like in your code: List<Class<BaseClass>> a = new ArrayList<Class<BaseClass>>(); it won't work because Class<ClassA> is not a subtype of Class<BaseClass>, even if ClassA extends BaseClass. Demo here: http://ideone.com/SJGEIz...

How can you manually find the Java Development Kit when setting up Android Studio on a PC running Windows 8.1?

java,android,java-7

What I think possibly happened here is that your Path is not appropriately specified in Environment variables. Follow the steps and your problem should be fixed: Cancel the installation (For now) Open up the Control Panel Go to the "System and Security section" Click on "System" On the top left...

How Is the Default Max Permgen Size Defined:

java,java-7,windows-7-x64,eclipse-kepler,permgen

You are running a 64bit environment, which has a larger permgen default then the 32bit jre's. You get 30% more permgen, which is around 83 Megs, which in turn matches your values. This is also documented at Oracle's VM param page. Oracle VM Params ...

Java Generic and inheritage of Generic Class

java,generics,java-7

See if the following works, although I think it should: public class EntityConsumer { public <T extends Entity, M extends EntityContainer<T>> void consum(M container){ } } ...

COMM_UP cannot be resolved to a variable

java,eclipse,java-7

Use: AssociationChangeNotification.AssocChangeEvent.COMM_UP rather than just COMM_UP to refer to this value - it is an enum value in an inner class of the AssociationChangeNotification class so you must refer to it this way (or use more imports)....

Performance hit with binary literals in Java 6 as compared to Java 7

java,binary,java-7,java-6

When you call Integer.parse, the conversion of binary string representation is done at runtime, so some CPU cycles are spent to do it; When you use a binary constant, the conversion is done at compile time, so there is no performance hit. Method call takes more characters to write...

The method replace(String, ArrayList<>) is undefined for the type HashMap

java,hashmap,java-7

Map.replace was first declared in Java 1.8 (see the "since: 1.8" at the bottom). You must be compiling against the 1.8 JDK (even if you're compiling in 1.6 mode). It's possible to do this in an IDE, for instance: to set the language compatibility mode to one version, but compile...

What is the difference between PermGen and Metaspace?

java,java-8,java-7,permgen,metaspace

The main difference from a user perspective - which I think the previous answer does not stress enough - is that Metaspace by default auto increases its size (up to what the underlying OS provides), while PermGen always has a fixed maximum size. You can set a fixed maximum for...

Something wrong with servlet session invalidation with JSP

java,session,servlets,tomcat7,java-7

JSP automatically creates a session. To disable it add <%@ page session="false"%> ...

Cannot execute task with Ant

java,ant,java-7

Firstly on windows it's not uncommon for files belonging to another process or thread to prevent the deletion of a file. Secondly what exactly is the purpose of the sequential task in your ANT target? The documentation describes the tasks as follows: Sequential is a container task - it can...

Tomcat failing to startup

java,tomcat,java-8,java-7

This is an error caused by an invalid JVM command-line parameter. Here's one way to reproduce it: C:\>java -agentpath:D:\Program Files\blahblah Error occurred during initialization of VM Could not find agent library D:\Program in absolute path, with error: Can't find dependent libraries Check Tomcat's Java options. Run %CATALINA_HOME%\bin\tomcat8w.exe as administrator, navigate...

Use of Matchers.isNull() for generic classes

java,generics,mockito,java-7

Use the generic version of Matchers.eq(): doReturn(foo).when(bar).myMethod(anyString(), Matchers.<List<Integer>> eq(null)) Using Java 7 you have to add the type witness <List<Integer>> to help the compiler figure this all out. In Java 8, that's not required. For more info on that particular aspect, see the bottom paragraphs of this page....

try-with-resource close sequence : FileInputStream close executed three times

java,debugging,java-7,close,try-with-resources

See comment of @jb-nizet your decompiler did not show the correct things, which explains your question 1. For question 2 have a look at the Stream.path variable in the debugger. On my System this are not the Streams openend by you but Java 8 internal files like "/opt/Oracle_Java/jdk1.8.0_40/jre/lib/tzdb.dat", "/opt/Oracle_Java/jdk1.8.0_40/jre/lib/meta-index" and...

Generating random API key, 2 method provided, any difference?

java,security,random,java-7,api-key

JRE is generating cipher key in the same way as you are. You methods are thus equivalent.

try-with-resources where to wrap stream with InputStreamReader?

java,java-7

Which means the InputStreamReader is never closed Eh? In your code it is... And it will certainly handle the .close() of your resource stream as well. See below for more details... As @SotiriosDelimanolis mentions however you can declare more than one resource in the "resource block" of a try-with-resources...

UnsupportedClassVersionError due to java 7?

java,intellij-idea,java-8,java-7

No, you shouldn't need to download JDK 7. This is a project level setting. Here is how I do it on IntelliJ IDEA 14, but I suspect it is the same if you are on 13 or 12. Go to Settings->Build,Execution,Deployment->Compiler->Java Compiler. Under that tab you should see a Project-wide...

App built by API 19/JDK 6 on a Lollipop

android,java-7,android-5.0-lollipop

An app built using a previous API level should work the same on future platforms. Just like the Android API is constantly being updated, the JDK is as well. So, the dependencies will increase. It just means that the Android API 21 has dependencies on JDK 7....

Can there be a (Java 7) FileSystem for which a Path .isAbsolute() but has a null root?

java,java-7,java.nio.file

The Definition The interface states the following about roots: A root component, that identifies a file system hierarchy, may also be present. So as you see, the comment seems to imply that roots are used for file system hierarchies. Now we have to reason about what an absolute path is....

Java: must cast to short, cannot use shorthand 'S'

java,casting,java-7,short

According to the Java Language Specification, Section 3.10.1, the only integer type suffix for integer literals is L (or lower case l). An integer literal is of type long if it is suffixed with an ASCII letter L or l (ell); otherwise it is of type int (§4.2.1). The suffix...

J2SE interfaces specifications and implementations of those interfaces

java,interface,java-7

The case for java.sql.Connection is that the driver provides the implementation classes for this and other interfaces like java.sql.Statement, java.sql.ResultSet, and on. All the magic of binding the interface to the proper class implementation happens in the method DriverManager#getConnection, which calls an internal method private static Connection getConnection(String url, java.util.Properties...

How to express that type T must be of type U?

java,generics,java-8,java-7

Simply use public class Whatever<T extends U,U> ...

Should I use Java 7's try-with-resources statement for each line of log

java,java-7,writer,close,try-with-resources

No, you should not open and close a FileWriter every time you want to append a new line to your log file. You should: open the log file at the start of the application append to it call flush() and finally call close(). or if you want to use the...

Why can't I use the Java 7 diamond syntax with a guava ImmutableSortedMap.Builder

java,java-7,guava,diamond-operator

As Jeffrey pointed out, Java's type inference has some quirks. The diamond syntax can be used in place of the full type syntax only when you are calling a constructor of the Object type that you are assigning the variable to. The reason you CAN'T use the diamond syntax the...

Hibernate 4.3.5 to 4.0.1 Exception org.hibernate.loader.MultipleBagFetchException

hibernate,spring-mvc,tomcat,weblogic,java-7

I fixed this. It is basically due to multiple fetchtype.Eager in the entity class which is creating the problem. You can find full information about the fix in "http://blog.eyallupu.com/2010/06/hibernate-exception-simultaneously.html"

Why does `Class == Boolean.class` cause a compiler error when `T extends Comparable`?

java,generics,java-7,comparable

See javadoc of Object.getClass(), the return type of value.getClass() is Class<? extends |T|>, i.e., Class<? extends Comparable>. The type of expression value.getClass() undergoes wildcard capture before it's used further; therefore we see the captured type Class<capture#2-of ? extends Comparable> in messages. The question surrounding type==Boolean.class, according to JLS#15.21.3, depends on...

How do I get a JavaFX control to realize it's localBounds immediately upon initialization?

java,javafx,java-7

In your Marquee class, to animate the nodes you call getContentWidth(), which just gets the width of each node: private int getContentsWidth(){ int width = 0; for(Node node : getChildrenUnmodifiable()){ width += node.boundsInLocalProperty().get().getWidth(); } return width; } Then you instantiate your marquees, and start the animation: Marquee marqueeLeft = new...

JDK 7: Existing file gets empty on new File(“path/to/file.html”);

java,file-io,java-7

I doubt there's an error in File.createNewFile(). I don't yet fully grasp in which order you run your code, but are you aware that this sets the file size to zero? out = new PrintStream("/mnt/testfs.pdf", "UTF-8"); From the PrintStream(File file) Javadoc: file - The file to use as the destination...

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

java,resources,java-7,try-with-resources

You always have to define a new variable part of try-with-resources block. It is the current limitation of the implementation in Java 7/8. In Java 9 they consider supporting what you asked for natively. You can however use the following small trick: public static void main(String[] args) throws IOException {...

HIPI compile fail: class file for com.sun.image.codec.jpeg.JPEGDecodeParam not found

java,apache,hadoop,ant,java-7

For some people who may had same problem as me, it was simply Java version problem-HIPI must be compiled using Java 1.6 I think I can make later versions of Java to compile HIPI, but I haven't tried it. Instead, I just simply used hipi jar file located in the...

How to get files for current date only when picking all files that match a given Pattern

java,regex,unix,operating-system,java-7

Use File.lasModified method to compare file date modification, try this code: public static List<String> getLogFiles(String logLocation, final String pattern, String date) throws ParseException { File logDirectory = new File(logLocation); String[] files = new String[] {}; SimpleDateFormat f = new SimpleDateFormat("dd-MM-yyyy"); Date d = f.parse(date); long milliseconds = d.getTime(); if (logDirectory.isDirectory())...

Javafx application built in JDK 7 doesn't run with Java 8

javafx,java-8,java-7

Muskan answers was very helpful because gave me a hint to bundle a jre with my application. Actually I've not used launch4j instead I've used exe4j, which is very similar but I've used before. If you decide to use this approach you can find step by step here....

Weblogic domain is not getting created because of jrockit error

java-7,weblogic11g

I believe that WebLogic 10.3.5 only supports Suns Java JDK 1.6.0_24+ OR JRockit R28.1.3-1.6.0_24+. It appears as though Weblogic 10.3.5 is not compatible with Java 7, try re-installing/configurring with a Java 6 version installed. Source: Oracle Installation Docs...

Why can't I .invokeExact() here, even though the MethodType is OK?

java,java-7,methodhandle

When the compiler emits the invokeExact call, it records Object as the expected return type. From the MethodHandle javadoc (emphasis mine): As is usual with virtual methods, source-level calls to invokeExact and invoke compile to an invokevirtual instruction. More unusually, the compiler must record the actual argument types, and may...

Why is java ExecutorService newSingleThreadExecutor spawning two threads?

java,multithreading,java-7,executorservice,scheduledexecutorservice

The only reasonable conclusion is that you (or the framework) are creating two references of ExecutorTest and executing it twice. Add the identityHashCode of the object to your logging. System.out.printf("Thread -" + Thread.currentThread().getId() + " Current time: %tr with reference: %s%n ", new Date(), System.identityHashCode(ExecutorTest.this)); The same code without changes...

Hadoop 2.6.0 build on Windows 8.1 fails - Ant BuildException

maven,hadoop,build,windows-8.1,java-7

I had the same error. Fixed it by making sure the cmake wasn't the one that comes with cygwin. For some reason, that cmake doesn't recognize Visual Studio.

Normalizing integers

algorithm,java-7

Instead of floating point division, you can use an integer division with remainder. private static int [] divide(int ... num) { int [] ret = new int[num.length]; int sum = sum(num); int rem = 0; for (int i = 0; i < ret.length; i++) { int count = num[i]*100 +...

Try with Resources: Resource leak while closing resources in TWR block

java,java-7,try-with-resources,resource-leak

So if while closing an FileInputStream an expression exception is generated, since the expression exception will be suppressed , the resource is not closed... You don't know it isn't closed, just that you got an exception while closing it. ... Will it generate a resource leak ? It may...

Shortest way to extract Map from List in Java

java,collections,java-7,guava

Often I find the decision whether to use Guava or not difficult. According to the Guava's own caveats docu, you should refrain from using Guava, if there is no net saving of lines of code or a clear performance benefit. However, in your case I fail to see an easy...

java7 diamond operator convert compilation error

java,regex,java-7

Try this : (?s)new (\w+)<.+>(\(.*?\);) String test = "List<String> t = new ArrayList<String>();"; System.out.println(test.replaceAll("(?s)new (\\w+)<.+>(\\(.*?\\);)", "new $1<>$2")); String test2 = "List<String> t = new ArrayList<String>(getList());"; System.out.println(test2.replaceAll("(?s)new (\\w+)<.+>(\\(.*?\\);)", "new $1<>$2")); String test3 = "List<String> t = new ArrayList<String>(\n\tgetList(\n\t\tanotherMethod()\n\t)\n);";...

Play! framework Java Promise example

java,playframework-2.0,promise,java-7

From play documentation: Maps this promise to a promise of type B. The function function is applied as soon as the promise is redeemed. The function: new Function<Double,Result>() { public Result apply(Double pi) { return ok("PI value computed: " + pi); } } will convert the pi value of type...

Java 1.7 + JSCH: java.security.InvalidKeyException: Key is too long for this algorithm

java,java-7,sftp,jsch,jce

We ended up swapping JSCH out for SSHJ. It depends on the BouncyCastle crypto libraries rather than on Java's built-in crypto packages, and is capable of connecting to our server with no problems.

JRuby Java Version Compatibility

java,version,jruby,java-7,java-5

From JRuby 1.7.0. Released: Java 5 support dropped (Java 6+ required) Bugs running under Java 8 are actively fixed (e.g. #1899, #1858)....

Java erased -> compile time type alignment - or Java Library/Framework code transitioning to application logic

java,generics,java-7,erasure,type-polymorphism

The problem you are having is because the method updateSimple requires all generic types to be T, this means: any but all equal! However you give different types for the generic parameters, respectively. ? (any), Object and ? (does not have to be the same as the one before). So...

Get the JDK version which is eclipse using to compile my current projects

java,eclipse,ide,java-7,java-6

Eclipse has its own Java compiler, it does not use the JDK compiler. The 'Preferences > Java > Compiler' preferences set which language level the Eclipse compiler uses. You can also override this for individual projects in the 'Java Compiler' Property page for the project. The 'JRE System Library' setting...

How to use Java 7+ Objects.hash with arrays?

java,arrays,java-7,hashcode

You could try: Objects.hash(field1, field2, Arrays.hashCode(array1), Arrays.hashCode(array2)); This is the same as creating one array that contains field1, field2, the contents of array1 and the contents of array2. Then computing Arrays.hashCode on this array....

ExecutorService invokeAll deadlock

java-7,executorservice,java.util.concurrent

This behavior you observe is indeed the expected one. Consider the following: 1) Task3 counts up to Integer.MAX_VALUE - 5000, whereas Task1 and Task2 count up to Long.MAX_VALUE - 5000. All things being equal, this means that Task1 and Task2 will last 2^32 times longer than Task3, that's over 4...

Java JDK 8 IndexedPropertyDescriptor has changed since JDK 7 with List object

java,java-8,java-7,introspection

Well, the specification clearly says that an IndexedPropertyDescriptor may have additional array based accessor methods, nothing else. That hasn’t changed. What you have here are conflicting property methods defining a simple List<String> typed property and and an indexed String property of the same name. The List based methods were never...

Java7 multiple exception handling

java,exception-handling,java-7

Why compiler reports an error in last case, can't it figure out that FileNotFoundException is special case of IOException? Because FileNotFoundException is a subclass of IOException. In other words, the "FileNotFoundException |" part is redundant. The reason why the code below is ok... } catch(FileNotFoundException e) { ... }...

What means “javax.net.ssl.SSLHandshakeException: server certificate change is restrictedduring renegotiation” and how to prevent it?

tomcat,ssl,java-7

This error message in client layer code is a consequence of code hardening following "SSL V3.0 Poodle Vulnerability - CVE-2014-3566" in recent Java updates. And it is a bug - here are work-arounds in case you cannot update your JRE immediately: A first option is to force TLS protocol when...

How to display the time of a Date object based on DateFormat.SHORT and locale?

java,date,java-7

If what you want to display is the time part, what ou need to call is getTimeInstance(), and not getDateInstance(). This is the kind of answer that you should learn to find by yourself, simply by reading the javadoc: Use getDateInstance to get the normal date format for that country....

How do I force a generic method's return type?

java,generics,java-7,guava

You can specify return type generic type with: return Sets.<LivingEntity>newHashSet(player); Maybe it would be OK for you to return Set<? extends LivingEntity>, then you can write it as a return type: private Set<? extends LivingEntity> example() { return Sets.newHashSet(player); } ...