Thursday, November 30, 2017

Another poorly implemented feature of Eclipse: repository search

Eclipse is a champion at implementing in an extremely unappealing and inefficient way even the simplest feature.


Window/Show view/ Maven Repository, right click on central , "Full Index Enabled". Then "Rebuild Index" (this especially useful if you get an error about the index having to be rebuilt for Lucene 6)

Then open the POM.XML, click on the Dependencies tab, add, and where it says "enter groupId, artifactId..." type *junit*

On the status bar on the bottom right you will see "repository search" and an animated icon...

It's AMAZING how slow it is....

much faster to google for "maven junit" and you get immediately the GAV

Eclipse: Erroneous Clumsy Ludicrous Inefficient Pathetic Shitty Elephant


See http://www.vogella.com/tutorials/EclipseMaven/article.html

Wednesday, November 29, 2017

Adam Bien on Lambda and Runnable


Java 8 Basics: Method References from AdamBien on Vimeo.



This is my code:




public class TestRun {
 public static void main(String[] args) {
  TestRun testRun = new TestRun();
  testRun.method1();
  testRun.method2();
  testRun.method3();
  testRun.method4();
 }

 
 /**
  * Old Java school
  */
 public void method1() {
  Runnable runnable = new Runnable() {
   @Override
   public void run() {
    System.out.println("ciao1");

   }
  };
  new Thread(runnable).start();
 }

 /**
  * Runnable's only method has no input parameters and only 1 method, 
  * it's a Functional Interface https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html 
  * so we provide method implementation inline (lambda)
  */
 public void method2() {
  Runnable runnable = () -> {
   System.out.println("ciao2");
  };
  new Thread(runnable).start();
 }
 
 /**
  * Syntactic sugar, since there is no parameter we omit the () notation altogether
  */
 public void method3() {
  Runnable runnable = () -> System.out.println("ciao3");
  new Thread(runnable).start();
 }
 
 /**
  * We provide the method (lambda) as a reference
  */
 
 public void method4() {
  Runnable runnable = this::display;
  new Thread(runnable).start();
 }
 
 
 public void display() {
  System.out.println("ciao4");
 }
}



Tuesday, November 28, 2017

WebSockets on WildFly and Eclipse

I have followed this (messy) tutorial, and eventually I have made it work on Wildfly - after a long struggle

http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/HomeWebsocket/WebsocketHome.html#overview


Here is the github repository https://github.com/vernetto/websocket


Just enter in 2 different browser this URL http://localhost:8080/WebsocketHome/


You need these classes

https://docs.oracle.com/javaee/7/api/javax/websocket/ClientEndpoint.html "POJO is a web socket client" and has a method annotated with @Message https://docs.oracle.com/javaee/7/api/javax/websocket/OnMessage.html