改變執行序的優先順序 Windows process priority via command line

在Linux有renice

renice -5 PID

但在Microsoft Windows得用
cmd.exe /c start "Process Monitor" /High "C:\tomcat\bin\tomcat8.exe"
或是

wmic process where name="tomcat8.exe" CALL setpriority “above normal"

參考:https://superuser.com/questions/620724/changing-windows-process-priority-via-command-line

廣告
張貼在 Uncategorized | 發表留言

以Maven專案建立Runable Jar檔案的pom.xml

參考:https://stackoverflow.com/questions/1729054/including-dependencies-in-a-jar-with-maven

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.test.TestMain</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>

張貼在 Uncategorized | 發表留言

HTML 5 Canvas paint

http://literallycanvas.com
http://literallycanvas.com

張貼在 Uncategorized | 發表留言

Google reCapacha

<%@page import="java.net.*, java.io.*"%>

<%@page import="java.net.*, java.io.*"%>

<%@ page language="java" contentType="text/html; charset=UTF-8″ pageEncoding="UTF-8″%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %><%  response.setCharacterEncoding(“UTF-8″); request.setCharacterEncoding(“UTF-8″);%>

 

<% String g_recaptcha_response = (String)request.getParameter(“g-recaptcha-response"); String secret="6Lep5yUUAAAAANxHjoIVJl9Vc6PhD1qlA8sbYnG1″; URL dest = new URL(“https://www.google.com/recaptcha/api/siteverify?secret="+secret+"&response="+g_recaptcha_response); URLConnection yc = dest.openConnection(); BufferedReader in = new BufferedReader( new InputStreamReader( yc.getInputStream())); StringBuffer sb = new StringBuffer(); String inputLine; while ((inputLine = in.readLine()) != null){ sb.append(inputLine); } if (!sb.toString().matches(“.+\"success\"\\s*:\\s*true\\s*.+") ) out.println(sb.toString()); in.close();%>

 

張貼在 Uncategorized | 發表留言

Tomcat SSL KeyStore JKS擷取private key

參考:https://security.stackexchange.com/questions/3779/how-can-i-export-my-private-key-from-a-java-keytool-keystore

keytool -importkeystore -srckeystore ./localhost.keystore -destkeystore ./localhost.p12.pfx -srcstoretype jks -deststoretype PKCS12 -srcalias tomcat -destalias tomcat

openssl pkcs12 -in ./localhost.p12.pfx -nocerts -nodes -out ./localhost.private.key

 

張貼在 Uncategorized | 發表留言

Tomcat 8 加入 Microsoft Service服務後,增加記憶體設定

參考:

https://tomcat.apache.org/tomcat-8.5-doc/windows-service-howto.html

tomcat8.exe //US//Tomcat8 --JvmMs 512 --JvmMx 4096

張貼在 Uncategorized | 發表留言

Android 以OkHttp3 連結網路

參考:https://square.github.io/okhttp/3.x/okhttp/index.html

okhttp3.OkHttpClient.Builder okhttp3Builder = new okhttp3.OkHttpClient.Builder();
okhttp3Builder.readTimeout(10, TimeUnit.SECONDS);
okhttp3Builder.connectTimeout(10, TimeUnit.SECONDS);
OkHttpClient client = okhttp3Builder.build();
okhttp3.Request.Builder requestBuilder = new Request.Builder().url(urls[0]);
if ( urls.length > 1) {
    okhttp3.FormBody.Builder formBodyBuilder = new okhttp3.FormBody.Builder();
    for (int i = 1; i < urls.length; i = i + 2) {
        formBodyBuilder.add(urls[i], urls[i + 1]);
    }
    requestBuilder.post(formBodyBuilder.build());
}
// // // Response response = client.newCall( new Request.Builder().url(urls[0]).build() ).execute();
try {
    Response response = client.newCall(requestBuilder.build()).execute();
    if (response.code() < 300)
        rtn = response.body().string();
} catch (java.io.IOException ex) {
}
張貼在 Uncategorized | 發表留言