修改/更新 Linux下原有的JDK/JRE

2012年2月25日 04:24

从官网下载的JDK是1.7x的。不过我的fedora15里默认安装的JRE是1.6x。结果导致使用JDK1.7x编译的class文件在JRE1.6x上无法解释。具体原因没有去考证。所以简单的解决这个问题,将JRE也更新到JRE1.7x。

其实JDK中也包含解释环境,所以没有必要再下载一个JRE,直接用JDK自带得java解释器就好。

于是乎,改/etc/profile啊之类的,加JAVA_HOME等都没有解决问题~

得,来个狠的。直接用自己安转的代替原有的。

 

# cd /usr/bin
# ln -s -f   /opt/jdk1.7.0_03/bin/java
# ln -s -f  /opt/jdk1.7.0_03/bin/javac

 

java -version确认一下~OK

 

技术还真是不碰就忘得一干二净……

Tags: java jre linux jdk
评论(5) 阅读(4557)

J2EE中那些忘却的~

2011年12月25日 21:57

1.About Struts2

1.1 The minimal required Struts 2 framework Jar files

  1. commons-fileupload-X.X.X.jar
  2. commons-io-X.X.X.jar
  3. commons-lang-X.X.jar
  4. commons-logging-X.X.X.jar
  5. commons-logging-api.X.X.jar
  6. freemarker-X.X.X.jar
  7. ognl-X.X.X.jar
  8. struts2-core-X.X.X.X.jar
  9. xwork-core-X.X.X.jar
  10. javassist-X.X.X.jar

1.2 To enable the Struts 2 framework to work with your web application you need to add a Servlet filter class and filter mapping to web.xml.

web.xml Servlet Filter
<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>

Note the url-pattern node value is /* meaning the Struts 2 filter will be applied to all URLs for this web application.

 

1.3 The minimal xml configuration. Note the file name is struts.xml and it should be in the src folder (struts.xml must be on the web application's root class path).

struts.xml
<?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.devMode" value="true" />

	<package name="basicstruts2" extends="struts-default">

		<action name="index">
			<result>/index.jsp</result>
		</action>

	</package>

</struts>

 

1.4 Struts2 use flow

  1. Create a class to store the welcome message (the model)
  2. Create a server page to present the message (the view)
  3. Create an Action class to control the interaction between the user, the model, and the view (the controller)
  4. Create a mapping (struts.xml) to couple the Action class and view

 

 

2.About Log4J

2.1 Download path:    http://archive.apache.org/dist/logging/log4j/

2.2 Setup a log4j.xml configuration in the src folder.

log4j.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
    
    <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
       <layout class="org.apache.log4j.PatternLayout"> 
          <param name="ConversionPattern" value="%d %-5p %c.%M:%L - %m%n"/> 
       </layout> 
    </appender>
 
    <!-- specify the logging level for loggers from other libraries -->
    <logger name="com.opensymphony">
    	<level value="DEBUG" />
    </logger>

    <logger name="org.apache.struts2">
    	 <level value="DEBUG" />
    </logger>
  
   <!-- for all other loggers log only debug and above log messages -->
     <root>
        <priority value="INFO"/> 
        <appender-ref ref="STDOUT" /> 
     </root> 
    
</log4j:configuration> 

 

 

Tags: java log4j struts
评论(11) 阅读(1617)