Posts

JMS Producer Consumer and Publisher Subscriber examples under Spring Boot

 In this article I will present Spring Boot code for a JMS Producer and a Consumer and also for a JMS Publisher and his Subscribers running under security in an Apache Artemis ActiveMQ running with Docker on localhost. While the article is being written, you can access its related code under the following links: GITHUB: Producer's code:  https://github.com/sciencetechworks/jmscommunications Consumer's code: https://github.com/sciencetechworks/jmscommunicationsb   Publisher's code: https://github.com/sciencetechworks/jmspublisher Subscribers' code: https://github.com/sciencetechworks/jmssubscriber Apache Artemis ActiveMQ docker image: https://github.com/vromero/activemq-artemis-docker docker run -it --rm -p 8161:8161 -p 61616:61616 vromero/activemq-artemis Enjoy!

Sending CRUD (POST,GET,UPDATE,DELETE) messages to a Quarkus REST Service from an HTML Page.

Quarkus: Sending CRUD (POST,GET,UPDATE,DELETE) messages to a Quarkus REST Service from an HTML Page. Given the a simple REST Service in Quarkus for basic CRUD operations (Create, Read, Update, Delete) calling the Read operation is as simple as invoking a GET method from an HTML form. On the other hand, invoking Create, Update and Delete normally implies sending an ID and/or some Data to the service. HTML Forms allow basic GET and POST methods, but no UPDATE and DELETE are offered by them. To solve this situation JQuery AJAX calls are necessary. Let the following simple REST service be our target: package org . acme ; import javax . ws . rs . GET ; import javax . ws . rs . POST ; import javax . ws . rs . PUT ; import javax . ws . rs . Path ; import javax . ws . rs . Produces ; import javax . ws . rs . Consumes ; import javax . ws . rs . DELETE ; import javax . ws . rs . core . MediaType ; @ Path ( "/example/crud" ) public class CRUDResource { @ GET @ Produc

How to change SQLDeveloper language

Image
Create a direct access and add --AddVMOption=-Duser.language=en as a parameter. For example: C:\sqldeveloper\sqldeveloper.exe --AddVMOption=-Duser.language=en

Manage Windows Registry from JAVA

import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; import java.util.ArrayList; import java.util.List; import java.util.prefs.Preferences; public class WinRegistry {   // inspired by   // http://javabyexample.wisdomplug.com/java-concepts/34-core-java/62-java-registry-wrapper.html   // http://www.snipcode.org/java/1-java/23-java-class-for-accessing-reading-and-writing-from-windows-registry.html   // http://snipplr.com/view/6620/accessing-windows-registry-in-java/   public static final int HKEY_CURRENT_USER = 0x80000001;   public static final int HKEY_LOCAL_MACHINE = 0x80000002;   public static final int REG_SUCCESS = 0;   public static final int REG_NOTFOUND = 2;   public static final int REG_ACCESSDENIED = 5;   private static final int KEY_ALL_ACCESS = 0xf003f;   private static final int KEY_READ = 0x20019;   private static Preferences userRoot = Preferences.userRoot();   private stat

Read Windows Registry from JAVA

// Gets value from property, if it does not exist, gets it     // from Windows registry     private String getValueFromPropertyOrLocalMachineRegistry(Properties props,             String propname, String registryPath, String registrykey) {         String value = props.getProperty(propname);         if ((value == null) || (value.trim().isEmpty())) {             try {                 value = WinRegistry.readString(                         WinRegistry.HKEY_LOCAL_MACHINE,                         registryPath,                         registrykey);             } catch (Exception ex) {                 return value;             }         }         return value;     } ----------------------------------------------------------------------------------------------------------- import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; import java.util.ArrayList; import java.util.List; import java.u

JAVA JPA WITH HIBERNATE AND H2 Tutorial

Image
JAVA JPA WITH HIBERNATE AND H2 Tutorial Setting the environment: Download and install H2 Database http://www.h2database.com/html/download.html Create a connection to the database, in my case I am using Netbeans. Creation of a new Database Connection can be done from the Services Tab, Databases node: Have in mind that it is not possible to test the connection before the JDBC URL has been written into. Select the PUBLIC schema when asked. And put a name onto it, I decided to name it as "Hibernate 101 on H2" Download Hibernate http://sourceforge.net/projects/hibernate/files/hibernate3/ JPA with Hibernate: For the shake of portability and standarization we will be using JPA. Natively speaking, Hibernate relies onto a context configuration file -  hibernate.cfg -  and a single or many persistence configuration files  - hibernate.hbm.xml - .  On the other hand JPA configuration is based on just one file:  persistence.xml.  Netbeans offe