Linux Terminal Command: Find Java installed folder.

$ which java
/usr/bin/java

$ readlink -f $(which java)
/usr/lib/jvm/jdk1.7.0_79/bin/java

$ update-java-alternatives -l
java-1.7.0-openjdk-amd64 1071 /usr/lib/jvm/java-1.7.0-openjdk-amd64

$ alternatives --display java
java - status is auto.
link currently points to /usr/java/jdk1.6.0_25/bin/java
/usr/java/jdk1.6.0_25/bin/java - priority 1000
Current `best' version is /usr/java/jdk1.6.0_25/bin/java.

$ find /usr -name java
/usr/share/bash-completion/completions/java
find: `/usr/share/doc/google-chrome-stable': Permission denied
/usr/share/java
/usr/lib/jvm/jre1.6.0_45/bin/java
/usr/lib/jvm/jdk1.7.0_79/jre/bin/java
/usr/lib/jvm/jdk1.7.0_79/bin/java
/usr/lib/jvm/jdk1.6.0_45/db/demo/programs/scores/java
/usr/lib/jvm/jdk1.6.0_45/db/demo/programs/vtis/java
/usr/lib/jvm/jdk1.6.0_45/jre/bin/java
/usr/lib/jvm/jdk1.6.0_45/bin/java
/usr/lib/jvm/jdk1.8.0_91/jre/bin/java
/usr/lib/jvm/jdk1.8.0_91/bin/java
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
/usr/lib/jvm/java-7-openjdk-amd64/bin/java
/usr/lib/libreoffice/share/Scripts/java
/usr/bin/java

Linux Bash: Pause commands.

Enter solution
read -rsp $'Press enter to continue...\n'

Escape solution (with -d $'\e')
read -rsp $'Press escape to continue...\n' -d $'\e'

Any key solution (with -n 1)
read -rsp $'Press any key to continue...\n' -n 1 key
# echo $key

Question with preselected choice (with -ei $'Y')
read -rp $'Are you sure (Y/n) : ' -ei $'Y' key;
# echo $key

Timeout solution (with -t 5)
read -rsp $'Press any key or wait 5 seconds to continue...\n' -n 1 -t 5;

Sleep enhanced alias
read -rst 0.5; timeout=$?
# echo $timeout


Explanation


  • -r specifies raw mode, which don't allow combined characters like "\" or "^".
  • -s specifies silent mode, and because we don't need keyboard output.
  • -p $'prompt' specifies the prompt, which need to be between $' and ' to let spaces and escaped characters. Be careful, you must put between single quotes with dollars symbol to benefit escaped characters, otherwise you can use simple quotes.
  • -d $'\e' specifies escappe as delimiter charater, so as a final character for current entry, this is possible to put any character but be careful to put a character that the user can type.
  • -n 1 specifies that it only needs a single character.
  • -e specifies readline mode.
  • -i $'Y' specifies Y as initial text in readline mode.
  • -t 5 specifies a timeout of 5 seconds
  • key serve in case you need to know the input, in -n1 case, the key that has been pressed.
  • $? serve to know the exit code of the last program, for read, 142 in case of timeout, 0 correct input. Put $? in a variable as soon as possible if you need to test it after somes commands, because all commands would rewrite $?



Excel functions English and German.

Excel list functions of English language and German language. Press "Ctrl + F" to find function you want.

Font Awesome icons not show on Blogger/Blogspot.

Use this url stylesheet CSS to fix:
<link href='https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css' rel='stylesheet'/>

Convert int to String in Java.

Integer.toString(0123456789);
String.valueOf(0123456789);

Alphabet & Special characters.

The list alphabet & special characters of some a country (English, Czech Republic, Hungary, Romania, Poland, Belgium).

Getting the computer name using Windows in Java.

public String getComputerName_Windows() {
 Map env = System.getenv();
 if (env.containsKey("COMPUTERNAME")) {
  return (String) env.get("COMPUTERNAME");
 }
 return "unknown";
}