Back Home



Log4j async logger

    <?xml version="1.0" encoding="UTF-8"?>
        <configuration status="warn" name="MyApp" packages="">
            <File name="MyFile" fileName="logs/app.log">
                    <pattern>%d %p %c{1.} [%t] %m%n</pattern>
            <Async name="Async">
                <appender-ref ref="MyFile"/>
            <root level="error">
        <appender-ref ref="Async"/>


Command Line Options

import org.apache.commons.cli.BasicParser
import org.apache.commons.cli.CommandLine
import org.apache.commons.cli.CommandLineParser
import org.apache.commons.cli.DefaultParser
import org.apache.commons.cli.HelpFormatter
import org.apache.commons.cli.Options
 * Created by rdono on 02/05/2017.
class zipi {
     static void main (String [] args ) {
         // setup some Options object
         Options options = new Options();
         options.addOption("t", false, "display current time");
         // then parse the received requirements 
         CommandLineParser parser = new DefaultParser();
         CommandLine cmd = parser.parse(options, args);
         if (cmd.getOptions().size() == 0) {
             HelpFormatter formatter = new HelpFormatter();
             println(formatter.printHelp( "Bulk tool injector", options));

Interactive text input can be got with


To prevent Unirest logging the following configuration around cookies stops it

RequestConfig globalConfig = RequestConfig.custom()
HttpClient httpclient = HttpClients.custom().setDefaultRequestConfig(globalConfig).build();

Sites with invalid SSL certificates (often in development environments), we have to setup unirest with a HttpClient that does not freak out:

  private static HttpClient unsafeHttpClient;
    static {
        try {
            SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy() {
                public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                    return true;
            unsafeHttpClient = HttpClients.custom().setSSLContext(sslContext)
                    .setSSLHostnameVerifier(new NoopHostnameVerifier()).build();
        } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
    public static HttpClient getClient() {
        return unsafeHttpClient;
    public void testSitemapUp() throws Exception {
        HttpResponse<String> response = Unirest.get("")
        assertEquals(200, response.getStatus());

Console Applications

  • Clamshell-Cli is a framework for building console-based command-line applications in Java.
java_libraries.txt · Last modified: 2018/02/12 06:20 by root
RSS - 200 © CrosswireDigitialMedia Ltd