MD5 hash on modern java

To get a similar php md5 or postgresql md5 function on java then try this code.

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Md5Util {

public static String byteArrayToHex(byte[] a) {
       StringBuilder sb = new StringBuilder(a.length * 2);
       for(byte b: a)
          sb.append(String.format("%02x", b));
       return sb.toString();
}

public static String Hash(String input) throws NoSuchAlgorithmException {

    MessageDigest md = MessageDigest.getInstance("MD5");
    md.update(input.getBytes());
    byte[] digest = md.digest();
    return byteArrayToHex(digest);
}

}

Java Scripting on JDK 11

JDK 11 make java command can directly run source code like other scripting language or interpreter. Lets say we have a java source file called hello.java as follow.

public class Hello {
 
  public static void main(String[] args) {
    System.out.println(“Hello World!”);
  }
 
}
 
Run the file by executing :
java hello.java
 
It works!
 
 
 
End.

Netbeans 12 on OpenBSD 6.7

I have some disappointment on netbeans 11, because plugin activation problems i face. Netbeans 12 i feel different, no errors on plugin activation. Beginning my trials for Netbeans 12 LTS (yes its a long term support version), i downloaded a platform independent zip file and extract it on my home folder. I saw on the website that older version no longer supported, including Netbeans 11 ???

This trials run on OpenBSD 6.7 laptop. Open terminal and cd to netbeans12/bin. Execute ./netbeans& [enter]. The Netbeans 12 run with JDK 8 just fine (oldest JDK version supported by Netbeans 12). First time first , activate all installed plugin to see if any errors happen. No errors, its good down the road. Right away Netbeans 12 do a task of downloading repository, hmmm. This downloading stuff is new and it takes long time to complete, i leave it over night, maybe just my slow old laptop cant handle it :). So far its a positive experience and i will say its a good job to the developers.

Bleeding edge Netbeans 11.3 on DragonflyBSD 5.8

To install netbeans 11.3 do “pkg install netbeans” on your root terminal. It will take time to download 292MB netbeans + 60MB openjdk8 packages. After done installing dont forget to set PATH and JAVA_HOME environment variables. Edit your .profile file on home directory and add /usr/local/openjdk8 to “PATH=xxx:/usr/local/openjdk8; export PATH” statement. Also create JAVA_HOME=/usr/local/openjdk8; export JAVA_HOME.

jEdit

jEdit is a java based editor for programmer, so it will run on many platform : windows, linux, mac.

First download jEdit installer from the web.

I choose to download java based installer and start it on my windows based laptop.

After a while a dialog will show up.

 

Continue reading “jEdit”

JVM Heap Size

if you get low memory error when running java program then try to look heap size flags with this command.

java -XX:+PrintFlagsFinal -version | grep HeapSize

To see all JVM flags just run the command without the grep.