Multiple Oracle Javas On Windows – No Installs

Whether you want a portable JDK or you just don’t want to further muck up your Windows %PATH%, you can get a older or newer Java on your Windows machine without affecting other versions.

I found a link explaining how to do it here:, but in case it ‘goes away’, here are the steps:

So far this works for Java 1.7, should work with Java 1.8.

  1. Make sure you have 7-zip on your Windows. Download the installer from Oracle
  2. Open the executable installer with 7-zip and extract the single file inside
  3. Extract the files from the to where you want your JDK.
  4. From a Windows command prompt in the folder where you extract the files, run the following:

    for /R %f in (.\*.pack) do @"%cd%\bin\unpack200" -r -v -l "" "%f" "%~pf%~nf.jar"

Posted in Java | Leave a comment

WiFi From Linux Rescue CD

Using Finnix 111 rescue CD:

Generate wpa_supplicant.conf configuration file:

# wpa_passphrase ssid passphrase > /etc/wpa_supplicant.conf

If you have any funky characters like ‘@’ in your passphrase, escape with a ‘\’.

Find driver
# wpa_supplicant –help

Using the correct driver:
# wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf -B

My driver listed was ‘nl80211’. Also, do not add a space between the options and their arguments.

Use ifconfig to find the network interface.

# dhclient wlan0

Posted in Uncategorized | Leave a comment

Make Bamboo Shell Task Run Using Bash

Bamboo will call shell tasks on *nix agents using sh as opposed to Bash. For Debian agents, this means dash not bash. So, how do we redirect to bash? I found this snippet:

[code language=”bash”]
if [ “$(ps -p “$$” -o comm=)” != “bash” ]; then
# Taken from
bash “$0” “$@”
exit “$?”

Alas, though, looks like the link I copied and pasted from the post does not work. Here’s the post I snagged this from.

Posted in Bamboo, Bash, Snippets | Leave a comment

Hack Classpath In Gradle

I recently tried this to fix the Classpath in Gradle for compiling and testing. Works for compiling, bombs for the testing though. The Gradle plugin integration using jna-3.2.7 blows up during unit testing when the older API is not loaded. What a mess. At least this snippet should help for other scenarios.

[code language=”groovy”]
def fixTheCp(fc) {
def jnaGoodJars = fc.filter { == “jna-4.2.1.jar”

task(“fixCompileCp”) << { sourceSets.main.compileClasspath = fixTheCp(sourceSets.main.compileClasspath) sourceSets.main.runtimeClasspath = fixTheCp(sourceSets.main.runtimeClasspath) } task("fixTestCp") << { sourceSets.test.compileClasspath = fixTheCp(sourceSets.test.compileClasspath) sourceSets.test.runtimeClasspath = fixTheCp(sourceSets.test.runtimeClasspath) } compileJava.dependsOn fixCompileCp testClasses.dependsOn fixTestCp [/code]

Posted in Gradle, Snippets | Leave a comment

Hex Encode/Decode String In C#

The same code is posted all over the news groups and Internet, but here it is, easy as a snippet for myself and for you to use.

I don’t even get credit for this as what I have pretty much matches up to what other people have already posted.

This is much easier in Python.

Encode a byte array
[code language=”csharp”]
public static string HexEncode(byte[] data)
return BitConverter.ToString(data).Replace(“-“, string.Empty);

Decode a hex necoded string
[code language=”csharp”]
public static byte[] HexDecode(string hexEncoded)
int numChars = hexEncoded.Length;
byte[] retVal = new byte[numChars / 2];
for (int i = 0; i < numChars; i += 2) { retVal[i / 2] = Convert.ToByte(hexEncoded.Substring(i, 2), 16); } return retVal; } [/code]

Posted in C#, Snippets | Tagged | Leave a comment

How To Clean SVN Checkout Directory

I just love

git clean -xfd

but you just don’t get that with Subversion. Instead from your Bash shell (or Cygwin) prompt you can do:

svn status --no-ignore | egrep '^[?I]' | cut -c9- | sudo xargs -d \\n rm -r

I got that last one from

Oh, and on that same post, for PowerShell users I found

function svnclean{
svn status | foreach { if($_.StartsWith("?")) {Remove-Item $_.substring(8) -Verbose}

I could resist saving these two snippets, I know I will need them.

Posted in Bash, PowerShell | Leave a comment

Validate Windows User On Network In C++

Need to validate and/or impersonate a user on a Windows domain? I Googled for this a bit but the API call is fairly simple so here is a quick snippet:

[code language=cpp]
HANDLE htoken = nullptr;
BOOL retVal = LogonUserW(L”JoeUser”, L”JoesDomain”, L”JoesPasswordPlainText”, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &htoken)

if (!retVal)
dwError = ::GetLastError();
qDebug() << "Error: GetLastError returned: " << dwError; } else { ::CloseHandle(htoken); qDebug() << "Logon successful."; } [/code]

Posted in Uncategorized | Leave a comment

Refresh Icon Cache In Windows 7

This keeps me from having to reboot:

C:\Windows\system32\ie4uinit.exe -ClearIconCache

Posted in Snippets | Leave a comment

Hash File Using POCO

This is the first time I have had to create MD5 hashes for files in C++. I did find a library called POCO that has some very handy classes for doing this. I didn’t want to copy and paste code from work, so I created this simple example for hashing a single file and outputting the MD5 hash in a hex encoded string.

The hashing uses a chunk size of 1 MiB changes so the whole file is not loaded at once.

I will soon create another post on how to do this in Qt5 and post it then, updating this post with the link.

Check out the open source POCO C++ libraries at There are downloads for Windows. For Linux, you may be able to get packages from the main repositories for your distro.

[code language=”cpp”]

#include <iostream>
#include <fstream>
#include <Poco/DigestStream.h>
#include <Poco/MD5Engine.h>

int main(int argc, char** argv)
Poco::MD5Engine md5;

std::ifstream ifHash(“../DSC_0002.JPG”, std::ios::binary);
if (ifHash.is_open())
Poco::DigestInputStream isMd5(md5, ifHash);
size_t bufSize = 0x100000;
char* buf = new char[bufSize];, bufSize);
while ( (isMd5.rdstate() && std::ifstream::failbit) == 0 )
{, bufSize);

if ( (isMd5.rdstate() && std::ifstream::eofbit) != 0)
std::string digest;
digest = Poco::DigestEngine::digestToHex(md5.digest());
std::cout << digest.c_str() << std::endl;

delete [] buf;

Posted in C++, Cryptography | Tagged | Leave a comment

Keep Your Gnome Desktop Awake

These little bash snippets tell you how long in seconds before your screen locks and how to
keep your screen from going to sleep. This is for Gnome 3 in Linux.

To find the time in seconds before your screen goes to sleep:

[me@mybox ~]$ gsettings get org.gnome.desktop.session idle-delay
uint32 300

Set this setting to 0 to keep your screen from going to sleep:

[me@mybox ~]$ gsettings set org.gnome.desktop.session idle-delay 0

NOTE: Don’t set the idle-delay to 0 and leave the room for too long, because anybody has access to your logged in session.

Posted in Uncategorized | Leave a comment