Saturday, March 9, 2013
JavaFx project on GitHub
To learn JavaFx, I've began a small project on GitHub.
I use JavaFx 2 and Maven.Perhaps, It could help you to begin in your project.
See https://github.com/drieu/MetricViewer for more information.
Thursday, February 7, 2013
sbt.ResolveException: download failed: org.slf4j#slf4j-api;1.6.6
Problem
When I ran play run , I have the following error :
[error] (*:update) sbt.ResolveException: download failed: org.slf4j#slf4j-api;1.6.6!slf4j-api.jar
[warn] some of the dependencies were not recompiled properly, so classloader is not avaialable
vi ./project/plugins.sbt
You only have to edit this file and add the last version of play (2.1.0) :
Then you can launch play run again
When I ran play run , I have the following error :
[error] (*:update) sbt.ResolveException: download failed: org.slf4j#slf4j-api;1.6.6!slf4j-api.jar
[warn] some of the dependencies were not recompiled properly, so classloader is not avaialable
Solution
vi ./project/plugins.sbt
You only have to edit this file and add the last version of play (2.1.0) :
// Comment to get more information during initialization
logLevel := Level.Warn
// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.1.0")
Then you can launch play run again
Saturday, January 26, 2013
KnowledgeBlackBelt will definitely shut down.
Bad news ! KnowledgeBlackBelt will definitely shut down on Jan 31st 2013.
Content is available for free ...
play 2.1 : Create yout first projetc with IntelliJ Tips
Create a project with Play is easy :
$ play new my-app $ cd my-app $ play ideaHowever, I had some diificulties with how to import in IntelliJ.In the documentation, it says that you have to import a module.But it doesn't work for me.
To succes, I've just done the following :
File --> Open
And now it works every times :-)
Sunday, January 6, 2013
java 8 : Functional Interfaces
In this article, we will try to learn new Java 8 concept : functional interface. It's an entry point for using lambdas and other JAVA 8 features ...
Definition from JSR 335
A functional interface is an interface that has just one abstract method, and thus represents a single function contract. (In some cases, this "single" method may take the form of multiple abstract methods with override-equivalent signatures (8.4.2) inherited from superinterfaces; in this case, the inherited methods logically represent a single method.)
In addition to the usual process of creating an interface instance by declaring and instantiating a class, instances of functional interfaces can be created with lambda expressions, method references, or constructor references.
The function descriptor of a functional interface I is a method type—type parameters, formal parameter types, return types, and thrown types—that can be used to legally override the abstract method(s) of I.
In short, a functional interface is only one interface with just one abstract method. The goal of Functional Interface is to use JAVA 8 feature like lambdas.
Simple example
Here is a short example :
ICode.java
package fr.dr.practice;Main.java
/**
* Interface with just one abstract method.
*/
public interface ICode {
String generate(int codeNumber);
}
package fr.dr.practice;
/**
* Created with IntelliJ IDEA.
*/
public class Main {
public static String generateTmpCode(int newCode) {
ICode code = new ICode() {
@Override
public String generate(int codeNumber) {
return "MAIN_" + codeNumber + Math.random();
}
};
return code.generate(newCode);
}
public static String generateTmpCodeWithLambda(int newCode) {
ICode icode = codeNumber -> "MAIN_" + codeNumber + Math.random();
return icode.generate(newCode);
}
public static void main(String[] args) {
System.out.println(Main.generateTmpCode(12));
System.out.println(Main.generateTmpCodeWithLambda(12));
}
}
More complex examples
In some cases, this "single" method may take the form of multiple abstract methods with override-equivalent signatures (8.4.2) inherited from superinterfaces; in this case, the inherited methods logically represent a single method.
So, you can make the following because equals method is public in Object class :
public interface ICode {
String generate(int codeNumber);
boolean equals(Object obj);
}
But you can't make this because clone method (protected Object clone() throws CloneNotSupportedException {) isn't public in Object class :
public interface ICode {
String generate(int codeNumber);
Object clone();
}
Function descriptor
The JSR 335 add also a the concept of Functional descriptor.Here is an example from JSR :
interface X { void m() throws IOException; }
interface Y { void m() throws EOFException; }
interface Z { void m() throws ClassNotFoundException; }
interface XY extends X, Y {}
interface XYZ extends X, Y, Z {}
// XY has descriptor ()->void throws EOFException
// XYZ has descriptor ()->void (throws nothing)
Conclusion
Functional interface permits to use lambda or other JAVA 8 features.It exists yet some functional interface (e.g : java.util.Comparator ). Java 8 has also a new package : java.util.functions which defines new Functional Interface.You could see this good blog for example with it : http://datumedge.blogspot.fr/2012/06/java-8-lambdas.html.This article permits me to learn JAVA 8 feature.If you have comments or if you see errors, please post it ! In next article, we will study lambda feature ...
Wednesday, December 26, 2012
Technorati
Hi,
I just add my blog on Technorati with the reference : SNHEY74ZG7EV
I just add my blog on Technorati with the reference : SNHEY74ZG7EV
Wednesday, December 12, 2012
Paper about CRaSH : a shell to extends the JVM
I've made an article about an interesting new project : CRaSH
It was published on www.developpez.com.Now it is in french but it will be translate.He is a direct link to this paper : http://damienrieu.developpez.com/article/crash_ehcache_spring/
CRaSH permits to access to the JVM by Shell and then execute scripts that you have mage in JAVA or Groovy ...
It was published on www.developpez.com.Now it is in french but it will be translate.He is a direct link to this paper : http://damienrieu.developpez.com/article/crash_ehcache_spring/
CRaSH permits to access to the JVM by Shell and then execute scripts that you have mage in JAVA or Groovy ...
Subscribe to:
Posts (Atom)
