Wednesday, May 27, 2020

Compile libgrowl Java 2020

Compile libgrowl Java version




Introduction


Notification is an important software system.

libgrowl is a Java library to send notifications to Growl, there is a C implement libgrowl as well. libgrowl is an open source library.

If you do not have a Growl installed, you can install Growl for Windows, Growl 1.3.x for Mac OS. Growl 2.x is not free anymore, it was selling USD3.99 on macOS App Store.(Is now available free on App Store again). If you don't want to pay for it, you can install the binary from third party (check here), or try to compile one for yourself.

Refer to this blog to download the pre-compile binary http://blogs.umb.edu/michaelbazzinott001/2014/09/21/growl/

libgrowl on Sourceforge and Github


libgrowl sends notification to Growl through network connection, the GNTP network protocol. libgrowl was first hosted on sourceforge.net (by bananewazen) https://sourceforge.net/projects/libgrowl/, later it was mirrored to different Github repositories.

https://github.com/feilimb/libgrowl some said this is the original mirror.
https://github.com/sbower/libgrowl this was modified with maven build.

To compile the libgrowl is a very good practice for Java beginners.

Compile


libgrowl (feilimb)



$ git clone https://github.com/feilimb/libgrowl
$ tree libgrowl
libgrowl
├── build
│ ├── build.xml
│ └── libgrowl.jar
└── src
└── net
└── sf
└── libgrowl
├── Application.java
├── GrowlConnector.java

$ cd build


ant compile and ant jar will do the job

What if you don't have ant and want to do it manually?


$ cd libgrowl/build
$ javac ../src/net/sf/libgrowl/internal/*.java ../src/net/sf/libgrowl/*.java
⇒ no class files?


No class files? class files were generated in the source directory.

$ cd ../src/net/sf/libgrowl
$ java GrowlConnector
Error: Could not find or load main class GrowlConnector

$ java net.sf.libgrowl.GrowlConnector
Error: Could not find or load main class net.sf.libgrowl.GrowlConnector

What happen???

There are many ways to solve the above issue. This is how I do it.
$ cd libgrowl/build
$ javac -d . ../src/net/sf/libgrowl/*.java ../src/net/sf/libgrowl/internal/*.java
⇒ net/sf/libgrowl net/sf/libgrowl/internal
$ java net.sf.libgrowl.GrowlConnector localhost "libgrowl" "libgrowl" "Test" "Hello, world."
(Show Growl notification)

libgrowl (maven)


Maven is a software to build software lifecycle, it will download the necessary dependency from the Internet. It is supposed to make it easier to compile a bigger project, might not be in this case.

Note: The maven software lifecycle $ mvn clean compile test package

I am compiling on macOS Mojave.

$ git clone https://github.com/sbower/libgrowl
$ cd libgrowl
$ mvn compile
⇒ error

I am using Java 8. Compile with deprecated warning, but still able to generate 1.5 binary
$ javac -source 1.5 -target 1.5 HelloWorld.java
⇒ with warning.

But the maven 3.6.3 doesn't support 1.5 binary. My lazy quick fix, change the version in the pom file.

$ edit pom.xml
Change compiler source and target from 1.5 to 1.8

<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>

$ maven package
⇒ error, test not pass.

I just remove all the test cases. After successfully compile, try test the new compiled software following the testing session below.

Testing


Test Growl


You must have the Growl software installed to test. Optional: you can use the command line growlnotify to send notification to Growl.

If you are on macOS, you can install the growlnotify using homebrew.

$ brew install growlnotify

Test libgrowl


$ java -cp ./target/libgrowl.jar net.sf.libgrowl.GrowlConnector "host" "app name" "notification name" "title" "message"

$ java -cp ./target/libgrowl.jar net.sf.libgrowl.GrowlConnector localhost "libgrowl" "libgrowl" "Test" "Hello, world."
or
$ java -cp libgrowl.jar net.sf.libgrowl.GrowlConnector localhost "libgrowl" "libgrowl" "Test" "Hello, world."


Wednesday, May 20, 2020

Hardware Growler Fork Notification Software 2020

Hardware Growler Fork Notification Software 2020




Introduction


Growl is a notification software for macOS (Mac OS X), it looks nice and configurable eg. display location, duration stay on the screen. Growl is available on Windows systems as well. With Growl, you can have a universal notification system for application.

Growl started when there was no good notification system on Mac OS systems. Notification Center was included in Mac OS X 10.8 Mountain Lion in 2012. Growl can send notifications to macOS Notification Center.

Early days of Growl. A few Mac OS software bundle Growl with their software, eg. Adium, Dropbox, Adobe CS5 etc. Some users are angry because these software just install Growl on their system without them knowing it. Later Adobe made an announcement about it, here, https://blogs.adobe.com/deployment/2010/05/growl_installation_with_adobe.html.

Hardware Growler



Hardware Growler is a software that sends notifications (to Growler) when users plug in or unplug a device in the system.

Growl 2.0


Growl started as a free, open source notification software, but it started to charge USD3.99 on macOS App Store with version 2.0. Growl is licensed under BSD, so it can be used for commercial and close source.

Growl and Hardware Growler fork


Since Growl (and Hardware Growler) is open source, someone has mirror and fok the software. Now it can be found here:

https://github.com/pranav-prakash/HardwareGrowler-NC

I am not sure how to compile the above software. When I load it with Xcode (10.13.1), it warn me about 32 bit, so it may not works with macOS 10.5 Catalina.

This following Hardware Growler has been modified to send notification direct to macOS Notification Center. This software is small and easy to compile. https://github.com/cirrusj/HardwareGrowler. I have tried it on Mojave + Xcode 10.13.1.


$ git clone https://github.com/cirrusj/HardwareGrowler
$ cd HardwareGrowler
$ make
⇒ build/Debug/HardwareGrowler.app


Then run the HardwareGrowler.app, you can move/copy to /Application[/Utilities] folder.
I tried this on macOS 10.14 Mojave, it works.

If you just want the binary for Growl 2.0, you can check the blog here http://blogs.umb.edu/michaelbazzinott001/2014/09/21/growl/

Sunday, May 10, 2020

The Incomplete Jump Start VS Code Tutorial 1

The Incomplete Jump Start VS Code Tutorial for Beginners

Part 1: General



Introduction


This is a tutorial guide for beginners, a jump start to learn VS Code. It is based on an older version of VS Code, to be installed on older machines and software, eg. Mac OS X 10.9 Mavericks and 32bits Linux system.

VS Code (Visual Studio Code) is a lightweight programming editor. VS Code is positioned between a text editor and an IDE (Integrated Development Editor).

VS Code is an open source software developed by Microsoft! Written in TypeScript (JavaScript), available for Windows, Mac, Linux, all the 3 major platforms.

VS Code is getting popular recently (these few years), as an alternative to Eclipse.

Installation


Users can download the latest version from VS Code website https://code.visualstudio.com/Download, or older version from updates.

OS X 10.9 Mavericks


The working version is 1.35.1, it can be downloaded from https://code.visualstudio.com/updates/v1_35, direct link for Mac.

Linux (Debian)


Raspberry Pi Desktop, 32 bits only. Download the 32 bits deb file from here (https://update.code.visualstudio.com/1.35.1/linux-deb-ia32/stable). To install

$ sudo dpkg -i code_1.35.1-nnn_i386.deb

You can load VS Code from RPi > Programming > Visual Studio Code, or from shell command
$ code

Configuration


Disable update


The first thing I do after the download is disable the auto-update. The later or the latest updates doesn't work on my older system. The auto-updates just download and didn't check if the update version works on the system.

Code/File > Preferences > Settings > (search "update mode") > update: mode (v) none

Note: disable internet connection before configure, to prevent auto-update.

General Usage


Command Palette


You may need this command palette to issue commands, eg. restart VS Code. The shortcut is (Cmd/Ctrl+Shift+p). Or from menu, Code > View > Command Palette.

Restart VS Code


Exit the software and relaunch, or use Command Palette: [Developer: Reload Window], to restart the application.

The Layout



Sidebar

On the left side, there is a sidebar with icons. From top down, the icons are Explorer(files), Search, Version control (Git), Debug, Extensions. The bottom is the Manage icon.


Explorer

Beside the sidebar, on the top is the workspace, directory and files.


Files editor

Upper right is (file) content display.


Output

Lower right is output and error messages.

Sidebar



Explorer Icon.To access workspace, folder and files.


Search, this is very common icon.


Source Control, the default is Git.


Extensions. Install extra extensions here.

The bottom left icon is Manage, can access "Command Palette" here.

Working with VS Code


Workspace


The workspace in VS Code is virtual. A workspace is a collection of your working projects, you can add in different project folders into the workspace, save the workspace as a file.

Searching in the workspace goes through all the files in the workspace, even if they are located in different project folders. You can always remove the project folder if you are not working with it.

Create a project


You can try with python, php, C or Java. I am using Java as an examples here. The easiest way for me is to create a project folder from the terminal, and add the project folder in VS Code workspace.

$ mkdir test_java

In VS Code, click on Explorer icon (sidebar), right click on the workspace area, add folder to workspace. Choose the test_java folder.

Create a new file HelloWorld.java under test_java folder, edit the file, and save it:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}

Install extension: code runner



Extensions: Search code runner

Install Java Extensions Pack by Red Hat, Java Extensions Pack by Microsoft or just simply use the code runner extension.

Click on Extensions icon (sidebar), search "Code Runner", and install.

After installed, restart VS Code.

1. Normal exit and relaunch VS Code, or
2. Command Palette (Cmd/Ctrl+Shift+p), search [Reload Window].

Right click on the HelloWorld.java, "Run Code". Results will be displayed at output.


Output

Part 1 end. To be continue...