Affichage des articles dont le libellé est java. Afficher tous les articles
Affichage des articles dont le libellé est java. Afficher tous les articles

samedi 16 décembre 2017

Java concurrence

Aujourd'hui, le moindre équipement électronique - ordinateur, téléphone, tablette...  possède plusieurs cœurs, répartis sur un ou plusieurs processeurs. Si l'on souhaite en tirer le meilleur parti, il est nécessaire de se pencher sur les outils et librairies de la programmation concurrente. Dans l'article de Zenika, vous verrez des aspects de ce que sont les Threads, et comment les créer et les manipuler en Java.

dimanche 10 décembre 2017

Java 8 Concurrency Tutorial in three parts by Benjamin a Software Engineer.


  • Part 1: Threads and Executors (This part teaches concurrent programming in Java 8 with easily understood code examples)
  • Part 2: Synchronization and Locks (This part you learn how to synchronize access to mutable shared variables via the synchronized keyword, locks and semaphores)
  • Part 3: Atomic Variables and ConcurrentMap (Atomic Variables and Concurrent Maps. Both have been greatly improved with the introduction of lambda expressions and functional programming in  latest Java 8 release. All those new features are described in this last part of this serie)

lundi 13 mars 2017

How to Install Oracle Java 8 on Ubuntu 16.10 via PPA

If you want to run a program written in Java, then you will need to install JRE (Java Runtime Environment); if you want to begin developing Java programs, then you also need to install JDK (Java Development Kit) which includes JRE, no matter what operating system you use. This tutorial will be showing you how to install Oracle Java 8 on Ubuntu 16.10 via PPA. PPA (Using a Personal Package Archive (PPA), you can distribute software and updates directly to Ubuntu users. Create your source package, upload it and Launchpad will build binaries and then host them in your own apt repository.) method is easier and faster than manual installation.
sudo add-apt-repository ppa:webupd8team/java 
sudo apt-get update 
sudo apt-get install java-common oracle-java8-installer

mercredi 6 avril 2016

The Java™ Tutorials : Aggregate Operations

The Java Tutorials are practical guides for programmers who want to use the Java programming language to create applications. They include hundreds of complete, working examples, and dozens of lessons. Groups of related lessons are organized into "trails". (The full tutorials https://docs.oracle.com/javase/tutorial/)

Let us stress this week on

Aggregate Operations:

Prerequisite:  Lambda Expressions and Method References.

Then follow the Aggregate Operations tutorial

mardi 15 décembre 2015

Java Nio SSL Example

SSL is the secure communication protocol of choice for a large part of the Internet community. There are many applications of SSL in existence, since it is capable of securing any transmission over TCP. Secure HTTP, or HTTPS, is a familiar application of SSL in e-commerce or password transactions. Along with this popularity comes demands to use it with different I/O and threading models in order to satisfy the applications’ performance, scalability, footprint, and other requirements. There are demands to use it with blocking and non-blocking I/O channels, asynchronous I/O, input and output streams and byte buffers.The main point of the protocol is to provide privacy and reliability between two communicating applications. The following fundamental characteristics provide connection security.
Read javacodegeek tutorial : http://examples.javacodegeeks.com/core-java/nio/java-nio-ssl-example/

dimanche 17 mai 2015

Liste mise à jour des projets libres dans le cadre de l'enseignement au Cnam Liban

Projets GitHub publique (Java et Linux)

  • nsy107 Exemple programmation répartis en Java 
  • smb215-15 ToT (Track of Things) Le projet des auditeurs SMB215 en 2015
  • rsx20x  Support et exemples pour le cours RSX20x Canam Liban


jeudi 11 décembre 2014

Code Camp : Idée de projets de réalisation en J2ee

Idée 1: Gestion des dépenses familiales

connectabilité simple

Fonctionnalités initiales: (idées de départ)

  • L'application permet de saisir les dépense par catégories. 
  • Le responsable de la famille (ou l'utilisateur principal) définie les catégories et les utilisateurs.
  • Les utilisateurs saisissent les dépenses.
  • L'application permet de réaliser des états par catégories de dépense ou des états consolidé de dépenses.

Idée 2: 


dimanche 29 décembre 2013

HTML 5 Server Sent Events on Glassfish 4

SSE (Server Sent Events) is a Web Pushing technology which was developed under HTML 5 technology. So, what is Pushing?

Pushing
It is a transmission of data sets which of them are sent at regular intervals or in any time through the server application, in the direction of server – – – >browser, without need for any request of web browser. Serving Twitter updates currently in the web page at regular intervals, appearance of Facebook shares on screen when a new share is available, serving instant financial data (exchange rate of dollar, parity etc.) immediately to users’ screen can be given as examples for pushing scenerio.

Server Sent Events is not a unique technique used for pushing of http resource, in theprevious article, we mentioned how to provide data transmission to the web browser by LongPolling technique. I think this sequencing about Push technologies would not be wrong generally in this order;
Polling –> LongPolling –> ServerSent Events –> WebSocket
ServerSent Events is a technology that its developments is already continues, such as WebSocket technology. For this reason, I would like to mention that it is not useable in every web browser and that’s for sure it is supported by new generation web browsers.

SSE technology has a few additional features unlike other ones, such as automatic connection recovery when the connection is lost, routing the message to an certain function in event/resource broadcasts. For example, you can take a look at to the discussion about the comparison of SSE and WebSocket from the entry in StackOverFlow.
How the SSE works?
The logic of operation of SSE technology can be seen in the picture illustrated below. Ahandshake request is sent to SSE supported server by the web browser and server system returns a handshake response which is “text/event-stream” MIME type. After the handshake committed among web browser and SSE service, SSE service may send any amout of data at any time. jaxrs-sse

mercredi 18 décembre 2013

The try-with-resources Statement

The try-with-resources Statement

The try-with-resources statement is a try statement that declares one or more resources. A resource is an object that must be closed after the program is finished with it. The try-with-resources statement ensures that each resource is closed at the end of the statement. Any object that implementsjava.lang.AutoCloseable, which includes all objects which implement java.io.Closeable, can be used as a resource.
The following example reads the first line from a file. It uses an instance of BufferedReader to read data from the file. BufferedReader is a resource that must be closed after the program is finished with it:
static String readFirstLineFromFile(String path) throws IOException {
    try (BufferedReader br =
                   new BufferedReader(new FileReader(path))) {
        return br.readLine();
    }
}
In this example, the resource declared in the try-with-resources statement is a BufferedReader. The declaration statement appears within parentheses immediately after the try keyword. The class BufferedReader, in Java SE 7 and later, implements the interface java.lang.AutoCloseable. Because the BufferedReader instance is declared in a try-with-resource statement, it will be closed regardless of whether the try statement completes normally or abruptly (as a result of the method BufferedReader.readLine throwing an IOException).
Prior to Java SE 7, you can use a finally block to ensure that a resource is closed regardless of whether the try statement completes normally or abruptly. The following example uses a finally block instead of a try-with-resources statement:
static String readFirstLineFromFileWithFinallyBlock(String path)
                                                     throws IOException {
    BufferedReader br = new BufferedReader(new FileReader(path));
    try {
        return br.readLine();
    } finally {
        if (br != null) br.close();
    }
}
However, in this example, if the methods readLine and close both throw exceptions, then the method readFirstLineFromFileWithFinallyBlockthrows the exception thrown from the finally block; the exception thrown from the try block is suppressed. In contrast, in the examplereadFirstLineFromFile, if exceptions are thrown from both the try block and the try-with-resources statement, then the methodreadFirstLineFromFile throws the exception thrown from the try block; the exception thrown from the try-with-resources block is suppressed. In Java SE 7 and later, you can retrieve suppressed exceptions; see the section Suppressed Exceptions for more information.
You may declare one or more resources in a try-with-resources statement. The following example retrieves the names of the files packaged in the zip filezipFileName and creates a text file that contains the names of these files:
public static void writeToFileZipFileContents(String zipFileName,
                                           String outputFileName)
                                           throws java.io.IOException {

    java.nio.charset.Charset charset =
         java.nio.charset.StandardCharsets.US_ASCII;
    java.nio.file.Path outputFilePath =
         java.nio.file.Paths.get(outputFileName);

    // Open zip file and create output file with 
    // try-with-resources statement

    try (
        java.util.zip.ZipFile zf =
             new java.util.zip.ZipFile(zipFileName);
        java.io.BufferedWriter writer = 
            java.nio.file.Files.newBufferedWriter(outputFilePath, charset)
    ) {
        // Enumerate each entry
        for (java.util.Enumeration entries =
                                zf.entries(); entries.hasMoreElements();) {
            // Get the entry name and write it to the output file
            String newLine = System.getProperty("line.separator");
            String zipEntryName =
                 ((java.util.zip.ZipEntry)entries.nextElement()).getName() +
                 newLine;
            writer.write(zipEntryName, 0, zipEntryName.length());
        }
    }
}
In this example, the try-with-resources statement contains two declarations that are separated by a semicolon: ZipFile and BufferedWriter. When the block of code that directly follows it terminates, either normally or because of an exception, the close methods of the BufferedWriter and ZipFileobjects are automatically called in this order. Note that the close methods of resources are called in the opposite order of their creation.
The following example uses a try-with-resources statement to automatically close a java.sql.Statement object:
public static void viewTable(Connection con) throws SQLException {

    String query = "select COF_NAME, SUP_ID, PRICE, SALES, TOTAL from COFFEES";

    try (Statement stmt = con.createStatement()) {
        ResultSet rs = stmt.executeQuery(query);

        while (rs.next()) {
            String coffeeName = rs.getString("COF_NAME");
            int supplierID = rs.getInt("SUP_ID");
            float price = rs.getFloat("PRICE");
            int sales = rs.getInt("SALES");
            int total = rs.getInt("TOTAL");

            System.out.println(coffeeName + ", " + supplierID + ", " + 
                               price + ", " + sales + ", " + total);
        }
    } catch (SQLException e) {
        JDBCTutorialUtilities.printSQLException(e);
    }
}
The resource java.sql.Statement used in this example is part of the JDBC 4.1 and later API.
Note: A try-with-resources statement can have catch and finally blocks just like an ordinary try statement. In a try-with-resources statement, anycatch or finally block is run after the resources declared have been closed.

Suppressed Exceptions

An exception can be thrown from the block of code associated with the try-with-resources statement. In the example writeToFileZipFileContents, an exception can be thrown from the try block, and up to two exceptions can be thrown from the try-with-resources statement when it tries to close theZipFile and BufferedWriter objects. If an exception is thrown from the try block and one or more exceptions are thrown from the try-with-resources statement, then those exceptions thrown from the try-with-resources statement are suppressed, and the exception thrown by the block is the one that is thrown by the writeToFileZipFileContents method. You can retrieve these suppressed exceptions by calling the Throwable.getSuppressed method from the exception thrown by the try block.

Classes That Implement the AutoCloseable or Closeable Interface

See the Javadoc of the AutoCloseable and Closeable interfaces for a list of classes that implement either of these interfaces. The Closeable interface extends the AutoCloseable interface. The close method of the Closeable interface throws exceptions of type IOException while the close method of the AutoCloseable interface throws exceptions of type Exception. Consequently, subclasses of the AutoCloseable interface can override this behavior of the close method to throw specialized exceptions, such as IOException, or no exception at all.

mardi 17 décembre 2013

JASPERSOFT 5.5 : LES NOUVEAUTÉS

Jaspersoft logo
La version 5.5 de la suite décisionnelle, sortie fin octobre, propose de nouvelles fonctionnalités aux utilisateurs, notamment en termes d’analyse, de planification et de prise en main de l’outil.
L’aspect d’analyse a été mis en avant, notamment par l’enrichissement des fonctionnalités de visualisation des données et l’augmentation de sa rapidité.
Le bon déroulement de la planification des rapports est renforcé par la création d’un outil dédié qui permet également de les transférer, puis de les stocker dans un répertoire local ou sur un serveur distant via un FTP. L’ajout d’un système de notification en cas d’échec finalise ce processus de transfert.
Jaspersoft 5.5 capture 1
La prise en main de l’outil par des utilisateurs non confirmés et la navigation sont désormais plus accessibles, notamment grâce à la page d’accueil du serveur qui affiche directement le contenu, les tutoriels et les différentes fonctionnalités (sources de données, domaines, rapports Ad Hoc, rapports, etc.).
Jaspersoft 5.5 capture 2
Jaspersoft a également enrichi ses templates de rapports et créé de nouveaux types de graphiques pour le reporting Ah Hoc.
Jaspersoft 5.5 capture 3
D’autres évolutions sont notables, comme l’architecture du serveur, qui a été optimisée grâce à la prise en compte des charges réseau (clusters) ou encore des outils de filtrage qui permettent de paramétrer au maximum les données et donc des analyses sur d’importantes volumétries (problématiques du Big Data).
Enfin, le renouveau de l’outil iReport, désormais basé sur l’environnement Eclipse, qui reste l’outil de conception de rapports : Jaspersoft Studio.

samedi 14 septembre 2013

Java EE7 : Glassfish 4

Glassfish4




To learn more about the new Java EE 7 capabilites, read the Java EE 7 Tutorial.

mercredi 26 décembre 2012

Robot Master


Wired News (08/06/12) Christina Bonnington

Carnegie Mellon University professor Manuela Veloso has spent her career developing autonomous collaborative robots (CoBots).  The CoBots run a combination of C++, Python, and Java, and consist of a camera and laptop on a wheeled base, while a Microsoft Kinect is used for navigation and obstacle avoidance.  Users assign tasks to the CoBot via a Web interface, and once the task is completed, the CoBot can either return to its home base or move on to the next assigned task.  Veloso eventually wants to develop CoBots that can perform daily human tasks alongside their human masters.  "I decided that ... these robots ... need a symbiotic relationship with humans, and they need to proactively ask for help when they need help," Veloso says.  Her research is focused on symbiotic autonomy, in which robots move through the world by themselves, but if they come across uncertainties about their location, or if what they are doing surpasses the threshold of their capabilities, they stop and ask humans for help.  "The reason why I came up with symbiotic autonomy was exactly because I started looking at these robots performing tasks and services for humans as part of a team," Veloso says.
http://www.wired.com/gadgetlab/2012/08/worlds-most-wired-roboticist/

samedi 24 novembre 2012

Why join Lebanese Java User Group

Version française visitez "Lebanese Java User Group à L'ISAE Cnam Liban"


Groupe Utilsateurs Java : Liban
At Cnam Liban university (computer science and software engineerinf departement) students will have to deals in most of their courses with Java technologies. Cnam Liban was an early adopter of java technologies in official syllabus and curiculas

It was decided to create a Java User Group on java.net forge, we call it the  "Lebanese Java User Group" this Java User Group will have at least 3 goals:

  • Portal to all supports and materials concerning  (javacard, javamobile, j2se, j2ee, Android, and others ...)
  • Repository of all documents related to Java published by Teachers, students and members
  • Repository of programms and code for meanfull projects produced by  members of the "Lebanese Java User Group"

LJUG is a Java User Groups (JUGs)

Java User Groups (JUGs) are volunteer organizations that strive to distribute Java-related knowledge around the world. They provide a meeting place for Java users to get information, share resources and solutions, increase networking, expand Java Technology expertise, and above all, have fun. Take a look at the JUGs Community Objectives, to learn how your JUG can benefit from participation in this community!

Joining and Getting More Involved in LJUG Projects

If you want to get involved with LJUG project, you can do a couple of things.
  • You can click the Bookmark link on LJUG home page and instantly get an Observer role. This will add the project and its forum information to your MyPage.
  • If you want to get more involved, start connecting with other members of the project in that project's forums or mailing lists, and get to know how the project is being worked or managed. Once you get to know everyone, try asking one of the project administrators for a higher role in the project like Software Developer, tester or Content Developer.

Possible Roles

RoleDescription
AdministratorThe Big Cheese, Head Honcho, King of the Mountain. Owns the project and can do anything they like with it.
Software DeveloperTop level developer. Do what ever you want with the code.
TesterTests the project software to make sure it works. AKA quality assurance (QA) person.
Content DeveloperSecond level developer. We trust you, but not that much
ObserverYou are here to watch, comment, and connect.

mercredi 21 novembre 2012

New Java User Group

A new Java User Group is created at Cnam Liban

It is mainly hosted on java.net at http://java.net/projects/ljug/pages/Home

It still incubating

To join create a java.net account and send me an email with the username and motivation at ljug@cofares.net

This blog will be a complement for essential news about LJUG