跳到主要內容

發表文章

Find directories with specific size with Java. Recursive Function Demonstration.

The first function draft was generated by AI ChatGPT 3.5. But its comparative function was wrong and AI needed extra guidance to pinpoint that comparison of object in Java needs extra cares. Then its revised its recursive function. However the recursive function provided was still incorrect as it failed to count all the size of files and files inside the subfolders of a specific folder. Then I determined to finish it myself and here is my version. The DirectorySizeChecker is a Java program that allows users to check the sizes of directories in their file system. The program takes in a directory path and an optional minimum size in megabytes as command line arguments, and outputs the paths and sizes of all directories that are equal to or larger than the specified size. The program starts by setting a default minimum size of 100MB if no size argument is provided. It then checks if the correct number of arguments have been provided, and if the input directory exists and is indeed a direc...
最近的文章

VM fusion is free for personal use now. Intend to use Bootcamp partition in MacOS (as a VM)

VMWare is super sneaky in making the VM Fusion free for personal use (But it is now). There is no easy or obvious link from the VMWare main page to download the VM Fusion for personal use. May be it is their strategy. https://customerconnect.vmware.com/web/vmware/evalcenter?p=fusion-player-personal Nevertheless, after going through some registration. You can finally download the VM Fusion for MacOS. I am interested in VM Fusion (for personal use) mainly because I want to make use of the BootCamp partition in my old MacBook Air 2016 edition. I hope it will save up some space instead of having to install a full-blown VM. Haven't done it yet. Wish me good luck.

IIS connects to Tomcat. Bug in IIS URL redirect, http2

IIS connects to Web/Application Server Tomcat 9 IIS (Internet Information Server 10) on Windows 2016 server Plesk dropped support for connecting Tomcat from IIS. It is disgraceful. I was so disappointed to learn that. However, another exciting opportunity opened up as I learnt URL rewrite is powerful enough to take over the job and even with more elegant simplicity. So I gave it a try. Even without knowing many of its features, I was able to set it up that one of the sites mysub.yourdomain.com (not real domain, just as an example and I tried a few sites in my server) is pointing to a tomcat localhost at 8080. It sounds good enough. Right?   However, after setting the original site mysub.yourdomain.com for using https. All browsers in desktop platform and Android platform seemed to work. But browser in iOS version failed to open the https. After a few digging, some said in forum that it was a known bug https://stackoverflow.com/questions/49141004/ios-10-3-3-not-working-w...

Setup Tomcat HTTPS (with JDK 8 to Java 15) in 2 mins

  Setup Tomcat 9 HTTPS/SSL To have a quick view, you may see the video(s): https://www.youtube.com/watch?v=WDGoF13vhZU 1. Generate Keystore I am using JDK 15 to generate the keystore. But the steps are similar with Tomcat 6 + openjdk 8(as I have tried it before writing this doc) Use “keytool” command to create a self-signed certificate. During the keystore creation process, you need to assign a password and fill in the certificate’s details. D:\apache-tomcat-9.0.38\conf>keytool -genkey -alias tomcatks -keyalg RSA -keystore D:\apache-tomcat-9.0.38\conf\tomcatks When enter the passwords during generation, please make sure the two passwords you entered are the SAME. This is the requirement of Tomcat. Here is the abstract from Tomcat installation  Finally, you will be prompted for the key password , which is the password specifically for this Certificate (as opposed to any other Certificates stored in the same keystore file). You MUST use the same password here as was used f...

Installation of Subversion Server and Client on Windows Platform

1. Download Subversion latest version 2. Download Tortoise (Subversion Client) Latest version The latest version of the software has been downloaded in the folder Steps for Server Part 1. Install the server and install the Tortoise client on the Server computer (The reason to install Tortoise client on the server computer is because Tortoise client can help you to create and manage repository in the server computer and you can forget about the admin command of subversion server. Note that the newest version of Tortoise only uses file based repository and does not use BD format repository. The file based repository is recommended by Tortoise and community. 2. Create Repository in server using command line svnadmin create "m:\svn_repos or Using Tortoise Right click the m:\svn_repos directory and select create repository here 3. Run the Server. By the following command.(Assume subversion is installed at c:\subversion\) c:\subversion\bin\svnserve.exe --daemon --r...

Winzip AES with Java

Component for using Java to make a winzip AES compatible function is rare. I only find winzipaes from. The example code is minimal. We experience a situation recently that we need to implement Winzip AES functionality in an rather old project, which is using JDK1.3. Key points We use winzipaes from http://code.google.com/p/winzipaes/ Because we will use it in a rather old project, we changed the source code of winzipaes to make it support jdk1.3. Officially they do not have such version We change the source code of its dependent third party component bouncycastle bcprov-jdk13-144.jar http://www.bouncycastle.org/ Basically we just add zipaes to precede all of its original packages so that it does not collide with the earlier bouncycastle package we are using in the main projects. We add a class to support normal zip operation in the prototype Usage version 0.9 Usage 1): zipaes encrypt source zipfile password 2): zipaes decrypt zipfile dest password...

SFTP/SSH in JAVA

It is relatively hard to find code examples in Internet regarding SFTP and SSH in java. Here I have written an example to demonstrate its usage. Key points I make use of J2SSH v0.2.2 The demonstration program is capable of acting as a ssh mini shell run a batch of simple sftp commands stored in a specified file run a batch of simple ssh command stored in a specified file (not yet finished) Remark: Please note that the crew who made J2SSH has already totally rewritten all of its functions and make it available at commercial market Please do test the speed of the prototype before you decide on whether to use this package. We have tested that it is generally at least 10% slower than sftp version in Unix. Usage Application :Sftp/SSH client Author :Edmund Ng last update :2009-11-05 versi...