为了加速电脑上面的Android 模拟器,可以使用Intel Atom 模拟器,但是在升级到10.9 之后发生死机问题,开启到一半,电脑整个卡住。搜索了一下,需要到intel 下载针对 10.9 的补丁版本
下载地址为
http://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager/
为了加速电脑上面的Android 模拟器,可以使用Intel Atom 模拟器,但是在升级到10.9 之后发生死机问题,开启到一半,电脑整个卡住。搜索了一下,需要到intel 下载针对 10.9 的补丁版本
下载地址为
http://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager/
在Java中,如果需要设定代码执行的最长时间,即超时,可以用Java线程池ExecutorService类配合Future接口来实现。 Future接口是Java标准API的一部分,在java.util.concurrent包中。Future接口是Java线程Future模式的实 现,可以来进行异步计算。
Future模式可以这样来描述:我有一个任务,提交给了Future,Future替我完成这个任务。期间我自己可以去做任何想做的事情。一段时 间之后,我就便可以从Future那儿取出结果。就相当于下了一张订货单,一段时间后可以拿着提订单来提货,这期间可以干别的任何事情。其中Future 接口就是订货单,真正处理订单的是Executor类,它根据Future接口的要求来生产产品。
Future接口提供方法来检测任务是否被执行完,等待任务执行完获得结果,也可以设置任务执行的超时时间。这个设置超时的方法就是实现Java程 序执行超时的关键。
Future接口是一个泛型接口,严格的格式应该是Future,其中V代表了Future执行的任务返回值的类型。 Future接口的方法介绍如下:
Future的实现类有java.util.concurrent.FutureTask即 javax.swing.SwingWorker<t,v>。通常使用FutureTask来处理我们的任务。FutureTask类同时又 实现了Runnable接口,所以可以直接提交给Executor执行。使用FutureTask实现超时执行的代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
ExecutorService executor = Executors.newSingleThreadExecutor(); FutureTask<String> future = new FutureTask<String>(new Callable<String>() {//使用Callable接口作为构造参数 public String call() { //真正的任务在这里执行,这里的返回值类型为String,可以为任意类型 }}); executor.execute(future); //在这里可以做别的任何事情 try { result = future.get(5000, TimeUnit.MILLISECONDS); //取得结果,同时设置超时执行时间为5秒。同样可以用future.get(),不设置执行超时时间取得结果 } catch (InterruptedException e) { futureTask.cancel(true); } catch (ExecutionException e) { futureTask.cancel(true); } catch (TimeoutException e) { futureTask.cancel(true); } finally { executor.shutdown(); } |
不直接构造Future对象,也可以使用ExecutorService.submit方法来获得Future对象,submit方法即支持以 Callable接口类型,也支持Runnable接口作为参数,具有很大的灵活性。使用示例如下:
1 2 3 4 5 6 7 8 |
ExecutorService executor = Executors.newSingleThreadExecutor(); FutureTask<String> future = executor.submit( new Callable<String>() {//使用Callable接口作为构造参数 public String call() { //真正的任务在这里执行,这里的返回值类型为String,可以为任意类型 }}); //在这里可以做别的任何事情 //同上面取得结果的代码 |
Java代码编译成二进制class 文件,这个class 文件也可以反编译成源代码 ,除了注释外,原来的code 基本都可以看到。为了防止重要code 被泄露,我们往往需要混淆(Obfuscation code , 也就是把方法,字段,包和类这些java 元素的名称改成无意义的名称,这样代码结构没有变化,还可以运行,但是想弄懂代码的架构却很难。 proguard 就是这样的混淆工具,它可以分析一组class 的结构,根据用户的配置,然后把这些class 文件的可以混淆java 元素名混淆掉。在分析class 的同时,他还有其他两个功能,删除无效代码(Shrinking 收缩),和代码进行优化 (Optimization Options)。
缺省情况下,proguard 会混淆所有代码,但是下面几种情况是不能改变java 元素的名称,否则就会这样就会导致程序出错。
一, 我们用到反射的地方。
二, 我们代码依赖于系统的接口,比如被系统代码调用的回调方法,这种情况最复杂。
三, 是我们的java 元素名称是在配置文件中配置好的。
所以使用proguard时,我们需要有个配置文件告诉proguard 那些java 元素是不能混淆的。
这和前面讲的是一样的,可以参考前面的博客
这里主需要在pom.xml中添加一个struts-core的依赖即可:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.deppon.demo</groupId> <artifactId>test02</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>test02 Maven Webapp</name> <url>http://maven.apache.org</url> <!-- 属性配置 --> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <!-- 添加JUnit --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <!-- Struts2 依赖 --> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>2.3.1</version> </dependency> </dependencies> <build> <finalName>test02</finalName> </build> </project> |
之后,Maven会自动从网上下载struts2需要的其他依赖包,可以看一下这里:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
package com.deppon.test02.action; import com.opensymphony.xwork2.ActionSupport; public class UserAction extends ActionSupport { private static final long serialVersionUID = -1417237614181805435L; private String name; private String password; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } /** * 跳转到登录界面 * @return */ public String login_input() { return SUCCESS; } /** * 登录 * @return */ public String login() { System.out.println("name->" + name); System.out.println("password->" + password); return SUCCESS; } } |
struts.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.i18n.encoding" value="utf-8"></constant> <constant name="struts.multipart.maxSize" value="20971520"/> <constant name="struts.devMode" value="true" /> <package name="p_user" namespace="/" extends="struts-default"> <action name="login_input" class="com.deppon.test02.action.UserAction" method="login_input"> <result name="success"> /login.jsp </result> </action> <action name="login" class="com.deppon.test02.action.UserAction" method="login"> <result name="success"> /login_success.jsp </result> </action> </package> </struts> |
web.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> |
index.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>主页</title> </head> <body> <a href="login_input">去登陆</a> </body> </html> |
login.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>登录界面</title> </head> <body> <form action="login" method="post"> name:<input type="text" name="name" /> password:<input type="password" name="password" /> <input type="submit" value="登录" /> </form> </body> </html> |
login_success.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="s" uri="/struts-tags" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>登录成功</title> </head> <body> <s:form action="login" namespace="/" method="post"> <s:textfield name="name" label="name"></s:textfield> <s:password name="password" label="password"></s:password> <s:submit value="Login"></s:submit> </s:form> </body> </html> |
项目结构如下图所示:
按照前面的 使用Maven构建Web项目 来创建一个Web项目,然后创建下面的例子
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
package com.deppon.text01.action; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class UserServlet extends HttpServlet { private static final long serialVersionUID = 1L; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request , response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); response.setContentType("text/html;charset=utf-8"); String action = request.getParameter("action"); if("login_input".equals(action)) { request.getRequestDispatcher("login.jsp").forward(request , response); } else if("login".equals(action)) { String name = request.getParameter("name"); String password = request.getParameter("password"); System.out.println("name->" + name + ",password->" + password); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <servlet> <servlet-name>UserServlet</servlet-name> <servlet-class>com.deppon.text01.action.UserServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>UserServlet</servlet-name> <url-pattern>/user</url-pattern> </servlet-mapping> </web-app> |
3.修改pom.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.deppon.demo</groupId> <artifactId>test01</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>test01 Maven Webapp</name> <url>http://maven.apache.org</url> <!-- 属性配置 --> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <!-- 依赖配置 --> <dependencies> <!-- 添加JUnit --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <!-- 添加Servlet --> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency> </dependencies> <build> <finalName>test01</finalName> </build> </project> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Hello Maven</title> </head> <body> <p>大家好!</p> <a href="user?action=login_input">去登录</a> </body> </html> |
login.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>登录界面</title> </head> <body> <form action="user?action=login" method="post"> Name:<input type="text" name="name" /> Password:<input type="password" name="password" /> <input type="submit" value="登录" /> </form> </body> </html> |
项目结构如下图所示:
参考
如何安装?
在wp后台安装插件处,搜索Crayon Syntax Highlighter插件,你会看到一个满分的该插件,直接安装即可,wp会帮你下载并解压安装的。
如何设置?
在wp后台右边菜单栏 设置->Crayon 中,又该插件的详细设置选项。不懂的选项大家可以多试试。
如何使用?
使用方法与SyntaxHighlighter 类似,同样是在html编辑模式下,使用该类语言的标签,比如你的代码是C++,
[C++]
your code
[/C++](只是个例子)
代码效果:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
CMemPoolMgr::CMemPoolMgr(unsigned int poolsize /* = DEFAULT_POOLSIZE */, unsigned int poolunitsize /* = DEFAULT_POOLUNITSIZE */, unsigned int blockunitsize /* = DEFAULT_BLOCKUNITSIZE */) { m_nPoolSize = poolsize; m_nPoolUnitSize = poolunitsize; m_nBlockUnitSize = blockunitsize; m_nTotalMemPool = 0; m_nUsingMemPool = 0; m_TimeTick = GetTickCount(); #ifdef _DEBUG m_nCode = 0; #endif } |
相信这种方式还是比较简单吧。
如果你还嫌麻烦,那么请使用可视化模式下的工具吧,安装完Crayon后,可视化编辑第一行菜单最后一个是该插件的选项,你可以点击它,直接拷贝你想高亮的代码进入就可以了,效果如下图所示,可视化编辑,更方便了。
参考
参考 http://blog.csdn.net/yuguiyang1990/article/details/8796410
1.1 File -> New -> Other
或者如下图
在Mac下面的Eclipse Kepler中目录的位置有所变化
现在开始修改一些配置
Maven的项目有一些约定:src/main/java , src/main/resources , src/test/java , src/test/resources .那么,添加这些文件夹:(注意,创建文件夹有可能失败,比如Kepler 上面,此时,到目录下面直接创建文件夹然后刷新Eclipse项目就可以了)
输入Source Folder 的名字
创建完之后的目录结构:
在项目上,右键单击,选择 Build Path ->Configure Build Path
选择 Source标签,会显示4个Source Folder ,修改他们的 OutPut folder :
双击每个文件夹的Output folder,选择路径
src/main/java,src/main/resources,选择target /classes;
src/test/java ,src/test/resources, 选择target/test-classes;
修改完成后如下图所示:
修改JDK版本:选择 libraries 标签,选中JRE library,单击Edit按钮
选择系统默认的就可以了,单击 Finish 按钮:
最后,单击OK即可:
完成后,项目结构如下图:
2.3 将项目转换为Dynamic Web Project
在项目上右键单击,选择 Properties:
在左侧选择 Project Facets,单击右侧的 ”Convert faceted from “链接:
修改Java为你当前项目的JDK,并添加Dynamic Web Module ,最后单击”Further Configuration available“ 链接:
修改Content directory 为 src/main/webapp ,单击OK:
在一次单击OK,完成操作:
在项目上右键单击,选择Properties,在左侧选择Deployment Assembly
此处列表是,部署项目时,文件发布的路径。
1,我们删除test的两项,因为test是测试使用,并不需要部署。
2,设置将Maven的jar包发布到lib下。
Add -> Java Build Path Entries -> Maven Dependencies -> Finish
设置完成效果图
单击OK
完成后,项目结构如下图所示:
就这样,使用Maven构建的一个Web项目就完成了。
SVN默认可以不写注释提交,有时候可能忘记写注释,有的人也没有写注释的习惯,导致翻看history的时候都不知道做了哪些更改,可以依照以下步骤修改SVN配置,强制提交SVN前写注释
步骤:
1.进入svn/code/hooks目录,在svn版本库的hooks文件夹下面,复制模版pre-commit.tmpl
1 2 |
cp pre-commit.tmpl pre-commit chmod +x pre-commit |
2.编辑pre-commit文件:
1 2 3 4 5 |
$SVNLOOK log -t "$TXN" "$REPOS" | \ grep "[a-zA-Z0-9]" > /dev/null || exit 1 "$REPOS"/hooks/commit-access-control.pl "$REPOS" $TXN \ "$REPOS"/hooks/commit-access-control.cfg |
上面这几行注释掉(前面加#符号),在此位置添加如下几行:
1 2 3 4 5 6 7 8 9 10 |
#必须填写注释且不少于5个字 # Make sure that the log message contains some text. SVNLOOK=/usr/bin/svnlook #如果这句被注释掉,请打开注释 LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c` if [ "$LOGMSG" -lt 5 ];#要求注释不能少于5个字符,您可自定义 then echo -e "注释信息不能为空且不少于5个字!" 1>&2 exit 1 fi exit 0 |
对于Ubuntu 14.04.5
之前的版本
1 |
$ sudo add-apt-repository ppa:relan/exfat |
1 |
$ sudo apt-get update |
1 |
$ sudo apt-get install exfat-fuse |
对于Ubuntu 14.04.5
以及之后的版本
1 |
$ sudo apt-get install exfat-fuse |
I'm working on my usual projects on Eclipse, it'a a J2EE app, made with Spring, Hibernate and so on. I'm using tomcat7 for this (no particular reason, I don't exploit any new feature, I just wanted to try that). Every time I debug my application, it happens that eclipse debugger pops out like it has reached a breakpoint, but it is not the case, in fact it stops on a Java Source File that is ThreadPoolExecutor. There is no stack trace on the console, it just stops. Then if I click on resume it goes on and the app works perfectly. This is what shows in the debugger window:
Daemon Thread ["http-bio-8080"-exec-2] (Suspended (exception RuntimeException))
ThreadPoolExecutor$Worker.run() line: 912
TaskThread(Thread).run() line: 619
I really can't explain this, because I'm not using ThreadPoolExecutor at all. Must be something from Tomcat, Hibernate or spring. It's very annoying because I always have to resume during debugging.
Any clues?
The posted stack trace indicates that a RuntimeException was encountered in a Daemon thread. This is typically uncaught at runtime, unless the original developer caught and handled the exception.
Typically, the debugger in Eclipse is configured to suspend execution at the location where the exception was thrown, on all uncaught exceptions. Note that the exception might be handled later, lower down in the stack frame and might not lead to the thread being terminated. This would be cause of the behavior observed.
Configuring the behavior of Eclipse is straightforward - in the Preferences Dialog, the Debug pane under Java in the tree hierarchy, has the option titled "Suspend execution on uncaught exceptions", which can be unchecked.