转-MyEclipse9 破解方法

原文:http://blog.csdn.net/qqzhuyuehe/article/details/6803551

一、使用注册机

网上可以下载到MyEclipse9的注册机(myeclipse9_keygen_activator.exe),但是这个程序在64位环境下运行会报错,如下图:

通过命令行执行:java -jarsystemidtools.jar,可以发现是因为少了支持程序在64位环境下运行的:jniwrap64.dll。google了下,有专门的dll网站提供下载,但貌似服务器上文件丢失,下载不下来,所以这条路暂时走不通。

二、直接修改MyEclipse的激活校验源码

1、说明

关于MyEclipse的激活校验,我目前只找到三个类可以修改使其破解,分别是:

view plain

  1. com.genuitec.eclipse.core.ActivationValidator.class;  
  2. com.genuitec.eclipse.core.LicenseUtil.class;  
  3. com.genuitec.eclipse.core.activation.ProductActivator.class

com.genuitec.eclipse.core.ActivationValidator.class;

com.genuitec.eclipse.core.LicenseUtil.class;

com.genuitec.eclipse.core.activation.ProductActivator.class

经过实验,个人觉得修改第一个类最方便。

所有工具及其代码,后面会附上下载地址。

2、工具jar包准备

首先,列出所有要用到的工具jar包:

com.genuitec.eclipse.core_9.0.0.me201103181703.jar

com.genuitec.eclipse.core.common.platform_9.0.0.me201102091112.jar

org.eclipse.equinox.common_3.6.0.v20100503.jar

javassist-3.0.jar

其中,前三个都在MyEclipse的安装目录中,具体路径为:安装目录\Common\plugins

我们的ActivationValidator.class就在第一个jar包中,由于该类还引用了 com.genuitec.eclipse.core.util.PlatformUtil;org.eclipse.core.runtime.IStatus,所以还有加入另外两个jar包。

第四个javassist-3.0.jar是专门用来修改Java中的Class文件的工具jar包,其具体使用方法参考:http://hi.baidu.com/hi8818/blog/item/a6a3a35451cbcf6f853524d1.html

3、程序代码

首先,新建一个JavaProject,并在工程中导入上面的4个jar包,然后新建一个类,代码如下:

view plain

  1. import java.io.IOException;  
  2. import javassist.CannotCompileException;  
  3. import javassist.ClassPool;  
  4. import javassist.CtClass;  
  5. import javassist.CtMethod;  
  6. import javassist.NotFoundException;  
  7. import com.genuitec.eclipse.core.ActivationValidator;  
  8. import com.genuitec.eclipse.core.util.PlatformUtil;  
  9. import org.eclipse.core.runtime.IStatus;  
  10. /**
  11. * 直接修改MyEclipse的激活验证类的ActivationValidato的Class文件,使其验证短路,从而达到破解的效果
  12. * @author Administrator
  13. *
  14. */
  15. public class Program {  
  16. public static void main(String[] args) {  
  17. try {  
  18. // 
  19.             ClassPool pool = ClassPool.getDefault();  
  20. // 载入要修改的类
  21.             CtClass cc = pool.get(“com.genuitec.eclipse.core.ActivationValidator”);  
  22. // 载入要修改的方法
  23.             CtMethod fMethod = cc.getDeclaredMethod(“isExpired”);  
  24. // 重新设置方法体内容
  25.             fMethod.setBody(“return false;”);  
  26.             fMethod = cc.getDeclaredMethod(“isDecodeFailed”);  
  27.             fMethod.setBody(“return false;”);  
  28.             fMethod = cc.getDeclaredMethod(“isValidForLicense”);  
  29.             fMethod.setBody(“return true;”);  
  30.             fMethod = cc.getDeclaredMethod(“isValidForSystemId”);  
  31.             fMethod.setBody(“return true;”);  
  32.             fMethod = cc.getDeclaredMethod(“isValid”);  
  33.             fMethod.setBody(“return true;”);  
  34.             fMethod = cc.getDeclaredMethod(“validate”);  
  35.             fMethod.setBody(“{return com.genuitec.eclipse.core.util.PlatformUtil.getOKStatus();}”);  
  36. // 保存修改完成的Class文件到指定位置
  37.             cc.writeFile(“E:\\”);  
  38.         } catch (NotFoundException e) {  
  39.             e.printStackTrace();  
  40.         } catch (CannotCompileException e) {  
  41.             e.printStackTrace();  
  42.         } catch (IOException e) {  
  43.             e.printStackTrace();  
  44.         }  
  45.     }  

运行程序,会在E盘中生成ActivationValidator.class,目录层次为:E:\com\genuitec\eclipse\core \ActivationValidator.class,然后用该class,替换:安装目录\Common\plugins \com.genuitec.eclipse.core_9.0.0.me201103181703.jar中的相应class文件就OK了。

这段程序就是通过直接修改ActivationValidator.class文件,使其校验过程直接短路,达到破解的目的。

4、配置激活码文件:.myeclipse.properties

虽然,上面我们对校验过程进行短路,但是程序还有个是否为空的判断,因此,我们需要在属性文件(.myeclipse.properties)中配置一下激活码。

属性文件的位置为:C:\Users\Administrator\ .myeclipse.properties,如果属性文件不存在,可以手动创建之

激活码的值可以随便填。如:

view plain

  1. ##MyEclipse license file  
  2. #Sat Jul 30 10:02:15 CST 2011  
  3. LICENSE_KEY=pLR8ZC-855444-68678656297401489  
  4. LICENSEE=cloudcube.net  
  5. ACTIVATION_KEY=c7b12e72e28df89e8acff15a6003928c4039f930aff5323f584bbccc3ccdcd9a347877e26b2965c17eae77d7f3550ca54686e7ce887f5afa78a693ec03b40762118a8739c9d7bd6acb40d27a68d06dd2fafc7813fba8230b79670886070e1b96c710b7c1de6d032d0fbfada43e8976db482403327bb61a715aadb338edf9b968

这里的激活码随便配置,只是为了防止验证程序读取为空而已。

5、修改启动配置文件:myeclipse.ini

为了程序正常启动,我们需要避免MyEclipse进行完整性校验,否则,MyEclipse自检程序发现文件被改动时,将导致启动失败。由于本人没有找到也懒得去找完整性校验的代码类,所以直接修改配置文件,取消启动时校验。

配置文件位置:安装目录\MyEclipse9\myeclipse.ini,在文件最后添加如下两行:

-Dgenuitec.honorDevMode=true

-Dosgi.dev=true

6、破解完成

自此破解过程完成,成功启动MyEclipse9。

7、附

1、破解方法从网上收集,但加上自己的完整实践操作并加以整理;

2、工程代码请自行下载,地址:http://download.csdn.net/detail/qqzhuyuehe/3629128

收藏 M2Eclipse:Maven Eclipse插件无法搜索远程库的解决方法

使用Eclipse安装了maven插件之后,创建Maven工程,发现添加依赖“Add Dependency”的时候无法自动搜索远程库。

如果不能搜索远程库那用这个插件有啥用撒。。。

查遍了所有的maven配置文件都没发现问题。

最后发现是插件本身的问题。原因是远程库的索引没有成功的建立。

很有可能安装插件之后的某一次“Update Indexes”失败之后,导致默认的index“http://repo1.maven.org/maven2/”无法继续更新。所以每次都会报错: Unable to update index for central http ://repo1 .maven .org /maven2 / 。

也就说一次更新失败导致了以后的Update index都失败了。

这个时候执行以下操作:

http://readthefuckingmanual.net/error/2394/

Do in eclipse: window->show view->other->maven->maven indexes. One of the indexes is:

http://repo1.maven.org/maven2.

right-click on this one, and try rebuild index.
If that does not work, create a new index with the same address, and do a rebuild of that. With me that worked, and I could remove the original one. After this a restart of eclipse will NOT show the error anymore, and the add dependency search function operates as it should. Problem solved.

另外,参考 http://forum.springside.org.cn/redirect.php?tid=2876&goto=lastpost,可以获得加快索引建立的方法。

解决Spring Tool Suite和Maven2找不到JDK的问题

在运行Spring Tools Suite工具,创建Maven Project时,报eclipse找不到JDK环境,请配置Eclipse JDK环境。
打开E:\springsource\sts-2.3.0.RELEASE目录中的STS.ini文件,加入-vm参数,具体如下:
[color=Red][size=15]-vm
C:\Program Files\Java\jdk1.6.0_13\bin\javaw.exe[/size][/color]
-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
–launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-product
com.springsource.sts.ide
–launcher.XXMaxPermSize
256M
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx1G
-XX:MaxPermSize=256m

注:vm后面一定要加换行,也不知道是什么原因,不换行还是报错。

Ubuntu9.10 SpringSource STS 按键失灵的解决

在Ubuntu9.10系统上使用SpringSource STS 2.3的时候,【Finish】不响应鼠标但是响应键盘。
在网上找到了解决方案,是eclipse3.5的问题。
如下:
1、创建eclipse.sh Shell文件
1.1在STS的目录下创建eclipse.sh文件
#!/bin/sh
export GDK_NATIVE_WINDOWS=1
/home/bona/opt/springsource/sts-2.3.0.RELEASE/STS
#bona是用户名,最后一行是指定STS的路径,建议采用绝对路径。

1.2 执行命令 chomd a+x eclipse.sh

2、创建STS启动菜单
在/home/bona/.local/share/applications目录中创建sts.desktop文件。

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=null
Exec="/home/bona/opt/springsource/sts-2.3.0.RELEASE/eclipse.sh"
Categories=Development;Application;
Name=SpringSource Tool Suite
Name[en_US]=SpringSource Tool Suite
Comment="SpringSource Tool Suite of the IDE available."
Comment[en_US]="The Stable installs of MyEclipse represent the most recent stable releases of the IDE available."
Icon=/home/bona/opt/springsource/sts-2.3.0.RELEASE/icon.xpm
Icon[en_US]=/home/bona/opt/springsource/sts-2.3.0.RELEASE/icon.xpm
Blueprint=rb-578452

这样就可以在系统菜单Applications->programming->SpringSource Tool Suite启动STS。

Maven2 常用命令

mvn archetype:create :创建 Maven 项目

mvn compile :编译源代码

mvn test-compile :编译测试代码

mvn test : 运行应用程序中的单元测试

mvn site : 生成项目相关信息的网站

mvn clean :清除目标目录中的生成结果

mvn package : 依据项目生成 jar 文件

mvn install :在本地 Repository 中安装 jar

mvn eclipse:eclipse :生成 Eclipse 项目文件

生成项目

建一个 JAVA 项目 : mvn archetype:create -DgroupId=com.demo -DartifactId=App

建一个 web 项目 : mvn archetype:create -DgroupId=com.demo -DartifactId=web-app -DarchetypeArtifactId=maven-archetype-webapp

生成 Eclipse 项目

普通 Eclipse 项目执行 : mvn eclipse:eclipse

Eclipse WTP 项目执行 : mvn eclipse:eclipse –Dwtpversion=1.0

( wtp1.0 以上版本均可用)

pom.xml 文件基本节点介绍

:文件的根节点 .
: pom.xml 使用的对象模型版本 .
:创建项目的组织或团体的唯一 Id.
:项目的唯一 Id, 可视为项目名 .

:打包物的扩展名,一般有 JAR,WAR,EAR 等
:产品的版本号 .
:项目的显示名,常用于 Maven 生成的文档。
:组织的站点,常用于 Maven 生成的文档。
:项目的描述,常用于 Maven 生成的文档。

在 POM 4 中, 中还引入了 ,它主要管理依赖的部署。

目前 可以使用 5 个值:

compile :缺省值,适用于所有阶段,会随着项目一起发布。

provided :类似 compile ,期望 JDK 、容器或使用者会提供这个依赖。如 servlet.jar 。

runtime :只在运行时使用,如 JDBC 驱动,适用运行和测试阶段。

test :只在测试时使用,用于编译和运行测试代码。不会随项目发布。

system :类似 provided ,需要显式提供包含依赖的 jar , Maven 不会在 Repository 中查找它。

定义自己的结构

新建一个 archetype 项目 :

mvn archetype:create\
-DgroupId=cn.prof\
-DartifactId=prof-archetype\
-DarchetypeArtifactId=maven-archetype-archetype

主要的模板文件 : archetype-resources/pom.xml

修改其中内容

修改 META-INF/maven/archetype.xml 中定义了相关的 sources

安装此项目 : mvn install

执行下面的命令创建新目录的项目:

mvn archetype:create -DgroupId=com.mergere.mvnbook \
-DartifactId=proficio-example\
-DarchetypeGroupId=com.xxx.mvn\
-DarchetypeArtifactId= prof-archetype \
-DarchetypeVersion=1.0-SNAPSHOT

FDT3.5正式版已经发布

今天下午还在用MyEclipse8中安装FDT 3.5 Beta2,晚上回家再重新安装时,发现FDT3.5已经releases.

 

With version 3.5 of FDT we are introducing great new features for both MXML and ActionScript editor. While we are focused on bringing you the best MXML editor for flex development at this time, we are continually improving FDT.

FDT 3.5  Presentation

The FDT 3.5 Update was recently released. Watch the new features of FDT 3.5 live in action! Michael Plank shows you what’s new in FDT 3.5 and how you can use the great features.

Features and Improvements of FDT 3.5

Full Autocompletion Support in MXML Editor

AS3 Autocompletion in CDATA, quotes and curly braces

Search in MXML Files

Wizard for creating Top Level Variables and Functions

New and improved Code Templates

Autocompletion for MXML Tags

Autocompletion for event types

Watch that feature in action

Improved Quick Outline

Autocompletion for constant convention

Watch that feature in action

Semantic Highlighting and Autocompletion for inline XML

Watch that feature in action

New Quick Fixes

Watch that feature in action

Brand new Debugger

Variable folding and XML Preview are the new features in the debugger


收藏-Flex Builder 3 on Eclipse 3.5

当我在机器上安装了flexbuilder3和STS(SpringSource Tool Suite )2.3后,将flexbuilder以插件的方式加入到STS,编译源文件和样式文件会出现编译出错,一开始是以为是上次编译产生的垃圾文件产生的问 题,采用项目文件清除后再编译,问题还是在。

ConfigurationProblem logging info

java.lang.IllegalArgumentException: "The attribute value type is com.adobe.flexbuilder.project.compiler.internal.ProblemManager and expected is one of java.lang.String, Boolean, Integer"
at org.eclipse.core.internal.resources.MarkerInfo.checkValidAttribute(MarkerInfo.java:84)
at org.eclipse.core.internal.resources.MarkerInfo.setAttributes(MarkerInfo.java:172)
at org.eclipse.core.internal.resources.Marker.setAttributes(Marker.java:304)
at com.adobe.flexbuilder.project.compiler.internal.ProblemManager.createMarker(Unknown Source)
at com.adobe.flexbuilder.project.compiler.internal.ProblemManager.createMarker(Unknown Source)
at com.adobe.flexbuilder.project.compiler.internal.ProblemManager.logProblem(Unknown Source)
at com.adobe.flexbuilder.project.compiler.internal.ProblemManager.logInternalProblem(Unknown Source)
at com.adobe.flexbuilder.project.compiler.internal.FlexProjectBuilder.buildItem(Unknown Source)
at com.adobe.flexbuilder.project.compiler.internal.FlexProjectBuilder.build(Unknown Source)
at com.adobe.flexbuilder.project.compiler.internal.FlexIncrementalBuilder.build(Unknown Source)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:627)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:170)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:201)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:253)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:256)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:309)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:341)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:140)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:238)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

后来在网上找到是因为flexbuilder3采用eclipse3.3作为平台开发,而我是用eclipse3.5,需要做如下修改:

 

  1. 下载包 ProblemManager patch
  2. 解压下载的文件
  3. 到 Flex Builder安装目录
  4. 用winrar打开/eclipse/plugins/com.adobe.flexbuilder.project_3.0.204732/zornproject.jar文件
  5. 将刚才下载解压的文件目录 com拖到winrar中完成压缩
  6. 启动STS
  7. 成功编译项目

 英文网址:http://www.jamesward.com/2009/09/29/flex-builder-3-on-eclipse-3-5/?utm_campaign=BackType&utm_medium=bt.io-twitter&utm_source=&utm_content=backtype-tweetcount

 

Ubuntu下搭建Java开发环境

http://www.javaeye.com/topic/158133

安装与设置JDK

Sun JDK的安装基本上有两种方式:

    1. 通过Ubuntu提供的包管理工具进行安装

      Ubuntu在其包仓库里都包括有JDK的安装,只要sources.list设置正确,通过apt-get, aptitude, Synaptic Package Manager等都能安装,而且相关的设置也容易得多;在Ubuntu的新  发布版本里都带了JDK5.0,和JDK6.0的安装支持,而且版本都比较高,和Sun官方的发布没有很大的 版本落差.以Ubuntu7.10来说,提供的JDK5的版本为:1.5.0.13,JDK6的版本是1.6.03,算是很新的版本了.

这种安装方式缺点是:对JDK具体版本的可选择性不是很灵活,你若是想安装最新的JDK版本,或由于特殊的原因必须安装特定的JDK版本,可能就比较费劲了。

     所以,若以此种方式安装JDK,请先通过apt-cache search, aptitude, Synaptic Package Manager等工具查询你的Ubuntu发行版本可安装的JDK版本是否能符合你的开发要求;具体安装 步骤请看参阅部分提供的文档。
 
  2. 通过Sun网站提供的自解压包进行手动的安装
  
       这种方式显然有它的好处: 可自由选择JDK版本,能进行灵活的配置。其实JDK的配置是很简单的:能让系统找到JDK所在的目录(JAVA_HOME),以便调用其目录中bin目录下的相关命令脚本。

      在此以Ubuntu7.10系统,Sun JDK 6.0 update 4为例说明一下具体的安装方式:

     2.1.  从Sun站点下载jdk 6.0.4的Linux自解压文件 jdk-6u4-linux-i586.bin;

      2.2. 安装配置

          cd /usr/local/lib
           sudo cp /home/jdk-6u4-linux-i586.bin ./
           sudo chmod +x jdk-6u4-linux-i586.bin
           sudo ./jdk-6u4-linux-i586.bin

           执行最后一步命令后便在当前目录下多了一个“jdk1.6.0_04“的目录,里面是jdk-6u4-linux-i586.bin解压后JDK的全部文件;
            由于Ununtu本身带了gij的JVM实现,所以当你在Terminal输入:  "java -version"时会显示:
           java version "1.5.0"
           gij (GNU libgcj) version 4.2.1 (Ubuntu 4.2.1-5ubuntu5)

           的相关信息。也就是系统中有两个JVM实现,而且gij JVM还被其它的Ubuntu工具或软件使用;所以这种情况下就得使用 Debian提供的“update-alternatives“工具来完成程序多版本实现的选择了:
           sudo update-alternatives –display java
          发现系统只列举了gij  JVM;因为jdk6是通过手动解压安装的。
          现在输入下面的两行命令:
           sudo update-alternatives –install /usr/bin/java java /usr/local/lib/jdk1.6.0_04/bin/java 60
          sudo  update-alternatives –install /usr/bin/java java /usr/bin/gij-4.2 40

          注意1,2行尾的60,40是优先级;现在把JDK6设为了首选;
          输入: ls -l /etc/alternatives/java 发现JVM已经指向了jdk6的解压目录:
         lrwxrwxrwx 1 root root 35 2008-01-25 17:55 /etc/alternatives/java -> /usr/local/lib/jdk1.6.0_04/bin/java
         
         cd /usr/bin
         sudo cp java java.bak
          sudo ln -sf /etc/alternatives/java .

    
          现在再执行:
          java -version

           java version "1.6.0_04"
          Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
          Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)

           若想变更JVM实现,输入:
            sudo update-alternatives –config java
           进行配置;
       
      2. 3. 设置环境变量

          在/etc/profile中加入如下的内容:
         
          JAVA_HOME=/usr/local/lib/jdk1.6.0_04
          JRE_HOME=/usr/local/lib/jdk1.6.0_04/jre
          CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
          export JAVA_HOME JRE_HOME CLASSPATH
         

      okey, JDK安装配置完成。

安装与配置IDE

  1. Eclipse的安装与配置

   1.1 从eclise.org下载Eclipse开发平台
         如类似以下的文件:eclipse-java-europa-fall2-linux-gtk.tar.gz.

    1.2 解压文件
         sudo mkdir /usr/local/dev
         sudo mkdir /usr/src/dev
         sudo cp eclipse-java-europa-fall2-linux-gtk.tar.gz /usr/src/dev/
         cd /usr/src/dev
         tar zxvf eclipse-java-europa-fall2-linux-gtk.tar.gz  -C /usr/local/dev

    1.3 建立一个Eclipse可执行文件
          sudo touch /usr/bin/eclipse
          sudo chmod 755 /usr/bin/eclipse
          sudoedit /usr/bin/eclipse

          内容如下:
         #!/bin/sh
          export ECLIPSE_HOME="/usr/local/dev/eclipse"
          $ECLIPSE_HOME/eclipse $*

          现在打开Terminal,执行"eclipse"应该能打开Eclipse了。

    1.4 添加Eclipse到Gnome菜单中
         sudoedit /usr/share/applications/eclipse.desktop
         内容如下:
         [Desktop Entry]
         Encoding=UTF-8
         Name=Eclipse
         Comment=Eclipse IDE
         Exec=eclipse
         Icon=/usr/local/dev/eclipse/icon.xpm
         Terminal=false
         Type=Application
         Categories=GNOME;Application;Development;
         StartupNotify=true

  2. Netbeans的安装与配置   

2.1 从netbeans.org下载Netbeans开发平台
         如类似以下的文件: netbeans-6.0-javase-linux.sh.

    2.2 安装文件
         sudo cp netbeans-6.0-javase-linux.sh /usr/src/dev/
         cd /usr/src/dev
         sudo chmod 755 netbeans-6.0-javase-linux.sh
         sudo ./netbeans-6.0-javase-linux.sh

         执行最后一步后,出现安装界面,选择安装目录和JDK的位置,确定后完成安装,在当前目录生成了“netbeans-6.0"目录,里面是Netbeans的内容。

    2.3 建立一个Netbeans可执行文件
          sudo touch /usr/local/bin/netbeans
          sudo chmod 755 /usr/local/bin/netbeans
          sudoedit /usr/local/bin/netbeans

          内容如下:
         #!/bin/sh
          #!/bin/sh
          export NETNEANS_PATH="/usr/local/dev/netbeans-6.0/bin"
          $NETNEANS_PATH/netbeans $*

    2.4 添加Netbeans到Gnome菜单中
         sudoedit /usr/share/applications/netbeans.desktop
         内容如下:
         [Desktop Entry]
         Encoding=UTF-8
         Name=NetBeans6.0
         Comment=Sun Netbeans IDE
         Exec=netbeans
         Icon=/usr/local/dev/netbeans-6.0/nb6.0/netbeans.png
         Terminal=false
         Type=Application
         Categories=GNOME;Application;Development;
         StartupNotify=true
 
  
  3. IntelliJ Idea的安装与配置 

   3.1 从jetbrains.com下载IntelliJ开发平台
         如类似以下的文件:idea-7.0.2.tar.gz.

    3.2 解压文件
          sudo cp idea-7.0.2.tar.gz  /usr/src/dev/
         cd /usr/src/dev
         sudo tar zxvf idea-7.0.2.tar.gz   -C  /usr/local/dev
         sudo mv idea-7590 idea

    3.3 更改/etc/profile
        IntelliJ Idea启动将JAVA_HOME命名为"IDEA_JDK"  或"JDK_HOME",所以需在/etc/profile中添加JDK_HOME设置,更改后的/etc/profile为:
         
          JAVA_HOME=/usr/local/lib/jdk1.6.0_04
          JDK_HOME=/usr/local/lib/jdk1.6.0_04
          JRE_HOME=/usr/local/lib/jdk1.6.0_04/jre
          CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
          export JAVA_HOME JDK_HOME JRE_HOME CLASSPATH
         
      
         之后重启系统;

    3.4 建立一个Idea可执行文件
          sudo touch /usr/bin/idea
          sudo chmod 755  /usr/local/bin/idea
          sudoedit  /usr/local/bin/idea

          内容如下:
         #!/bin/sh
         export IDEA_PATH="/usr/local/dev/idea/bin"
         $IDEA_PATH/idea.sh$*

    3.5 添加IntelliJ Idea到Gnome菜单中
         sudoedit /usr/share/applications/eclipse.desktop
         内容如下:
         [Desktop Entry]
         Encoding=UTF-8
         Name=Idea
         Comment=IntelliJ Idea 7
         Exec=idea
         Icon=/usr/local/dev/idea/bin/idea32.png
         Terminal=false
         Type=Application
         Categories=GNOME;Application;Development;
         StartupNotify=true

  4. Emacs下的配置 
           请参考我写的另一篇文章: Emacs下配置Java开发环境

    参阅资料:

    1.  到Sun java站点下载JDK实现。

    2. 请参考Ubuntu Java文档中通过包管理工具的实现。

    3. serios.net中有关于Debian, Ubuntu下安装配置JRE,JDK的精彩说明。

   4. 参考How to Install Sun Java on Debian的另外一种安装方式。

   5. 参考update-alternatives的文档,看相关命令的操作。

   6. 到Eclipse站点下载Eclipse IDE for Java Developers.

   7. 看Ivar Abrahamsen关于Ubuntu下配置Elipse的精彩说明.

   8. 到Netbeans站点下载Netbeans IDE.

   9. 到Jetbrains站点下载IntelliJ IDEA.

myeclipse 7.5 keygen 源代码

转自http://blog.csdn.net/shadowkiss/archive/2009/07/30/4393610.aspx

 

Java代码
  1. import java.text.DecimalFormat;  
  2. import java.text.NumberFormat;  
  3. import java.text.SimpleDateFormat;  
  4. import java.util.Calendar;  
  5.   
  6. /** 
  7.  * myeclipse blue 7.5 keygen 
  8.  *  
  9.  * @author bona shen 
  10.  *  
  11.  */  
  12. public class Crack {  
  13.     public static final void main(String[] args) {  
  14.         String id = "bona"// 可更给为您的名字  
  15.         String num = "999";// 许可证数量  
  16.         System.out.println(getSerial(id, "100", num, false));  
  17.     }  
  18.   
  19.     public static String getSerial(String userId, String version,  
  20.             String licenseNum, boolean selected) {  
  21.         Calendar cal = Calendar.getInstance();  
  22.         cal.add(110);  
  23.         cal.add(6, -1);  
  24.         NumberFormat nf = new DecimalFormat("000");  
  25.         licenseNum = nf.format(Integer.valueOf(licenseNum));  
  26.         String verTime = selected ? (new StringBuffer("-")).append(  
  27.                 (new SimpleDateFormat("yyMMdd")).format(cal.getTime())).append(  
  28.                 "0").toString() : "-1012310";  
  29.         String type = "YE3MB-";  
  30.         String need = (new StringBuffer(String.valueOf(userId.substring(01))))  
  31.                 .append(type).append(version).append(licenseNum)  
  32.                 .append(verTime).toString();  
  33.         String dx = (new StringBuffer(String.valueOf(need)))  
  34.                 .append(  
  35.                         "Decompiling this copyrighted software is a violation of both your license agreement and the Digital Millenium Copyright Act of 1998 (http://www.loc.gov/copyright/legislation/dmca.pdf). Under section 1204 of the DMCA, penalties range up to a $500,000 fine or up to five years imprisonment for a first offense. Think about it; pay for a license, avoid prosecution, and feel better about yourself.")  
  36.                 .append(userId).toString();  
  37.         int suf = decode(dx);  
  38.         String code = (new StringBuffer(String.valueOf(need))).append(  
  39.                 String.valueOf(suf)).toString();  
  40.         return change(code);  
  41.     }  
  42.   
  43.     private static int decode(String s) {  
  44.         int i = 0;  
  45.         char ac[] = s.toCharArray();  
  46.         int j = 0;  
  47.         for (int k = ac.length; j < k; j++)  
  48.             i = 31 * i + ac[j];  
  49.         return Math.abs(i);  
  50.     }  
  51.   
  52.     private static String change(String s) {  
  53.         byte abyte0[] = s.getBytes();  
  54.         char ac[] = new char[s.length()];  
  55.         int i = 0;  
  56.         for (int k = abyte0.length; i < k; i++) {  
  57.             int j = abyte0[i];  
  58.             if (j >= 48 && j <= 57)  
  59.                 j = ((j - 48) + 5) % 10 + 48;  
  60.             else if (j >= 65 && j <= 90)  
  61.                 j = ((j - 65) + 13) % 26 + 65;  
  62.             else if (j >= 97 && j <= 122)  
  63.                 j = ((j - 97) + 13) % 26 + 97;  
  64.             ac[i] = (char) j;  
  65.         }  
  66.         return String.valueOf(ac);  
  67.     }  
  68. }  

运行就产生序列号。

如果不想动手可以用这个。

Subscriber: bona

Subscription:oLR8ZO-655444-65678656903184204

Subscription Detail:

Subscriber: bona
Product ID: E3MB (MyEclipse Blue Subscription)
License version: 1.0
Full Maintenance Included
Subscription expiration date (YYYYMMDD): 20101231
Number of licenses: 999

FDT 3.5 beta 破解

目前FDT已经发布了3.5beta版,下面是新功能的介绍EN版的。

What’s new in FDT 3.5

With version 3.5 of FDT we are introducing great new features for both MXML and ActionScript editor. While we are focused on bringing you the best MXML editor for flex development at this time, we are continually improving FDT.

There will be two beta testing phases before final release.

The public beta of FDT 3.5 Beta 1 is released since august 27th. Public beta release for FDT 3.5 Beta 2 is scheduled for the next weeks.

Update: Mac Snow Leopard users should update to the latest beta Version 3.5 Build 1033, FDT provides full support in this version.

Features and Improvements of FDT 3.5 beta 1

Autocompletion for MXML Tags

Autocompletion for event types

Watch that feature in action

Improved Quick Outline

Autocompletion for constant convention

Watch that feature in action

Semantic Highlighting and Autocompletion for inline XML

Watch that feature in action

New Quick Fixes

Watch that feature in action

Brand new Debugger

Variable folding and XML Preview are the new features in the debugger

Features and Improvements of FDT 3.5 beta 2

  • Autocompletion for ActionScript in MXML files
  • Search and Find References in MXML files

安装有两种方式,一种是all in one,一种是eclipse plugin。

FDT 3.5 beta for Windows

How to install FDT 3.5 beta in Eclipse?

  1. Install Eclipse (www.eclipse.org)
  2. Open Eclipse
  3. Select "Help->Software Updates->Find and install…"
  4. Select "Search for new features to install" and press next
  5. Press "New Remote Site…"
  6. Insert FDT into Name and "http://fdt.powerflasher.com/update_beta/" into URL
  7. Press finish

点击下载此文件

解压后放在eclipse plugin\安装目录com.powerflasher.fdt.core_3.5.0.1040文件夹中。

破解后的效果如下:

自定义 Tree Data descriptor

在做开源供应链管理系统的时候,会用到很多树形的描述,需要用到mx.controls.Tree来展现,而数据库表定义时,表内有相关联如下:

SQL代码

create table "materialStock"."dbo"."MaterialType"(
"autoId" _autoId not null,
"parentId" _autoId null,
"unit" _unit(20) null,
"name" _name(20) null,
constraint "XPKMaterialType" primary key ("autoId")
)
go

alter table "materialStock"."dbo"."MaterialType"
add constraint "R_6"
foreign key ("parentId")
references "materialStock"."dbo"."MaterialType"("autoId")
go
create unique index "XPKMaterialType" on "materialStock"."dbo"."MaterialType"("autoId")
go

通过JPA就自动生成如下JAVA代码:
Java代码

package com.csgjs.mm.model.domain;

import …

/**
* AbstractMaterialType entity provides the base persistence definition of the
* MaterialType entity.
*
* @author MyEclipse Persistence Tools
*/
@MappedSuperclass
public abstract class AbstractMaterialType implements java.io.Serializable {

// Fields

private Integer autoId;
private MaterialType materialType;
private String unit;
private String name;
private Set<MaterialType> materialTypes = new HashSet<MaterialType>(0);

// Constructors

…

public void setMaterialType(MaterialType materialType) {
this.materialType = materialType;
}

…

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "materialType")
public Set<MaterialCatalog> getMaterialCatalogs() {
return this.materialCatalogs;
}

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "materialType")
public Set<MaterialType> getMaterialTypes() {
return this.materialTypes;
}

public void setMaterialTypes(Set<MaterialType> materialTypes) {
this.materialTypes = materialTypes;
}

}

再由granite data service自动生成如下AS3类:

ActionScript代码

public class AbstractMaterialTypeBase implements IExternalizable {

private var __initialized:Boolean = true;
private var __detachedState:String = null;

private var _autoId:Number;
private var _materialType:MaterialType;
private var _materialTypes:ListCollectionView;
private var _name:String;
private var _unit:String;

meta function isInitialized(name:String = null):Boolean {
if (!name)
return __initialized;

var property:* = this[name];
return (
(!(property is AbstractMaterialType) || (property as AbstractMaterialType).meta::isInitialized()) &&
(!(property is IPersistentCollection) || (property as IPersistentCollection).isInitialized())
);
}

public function set autoId(value:Number):void {
_autoId = value;
}
public function get autoId():Number {
return _autoId;
}

public function set materialType(value:MaterialType):void {
_materialType = value;
}
public function get materialType():MaterialType {
return _materialType;
}

public function set materialTypes(value:ListCollectionView):void {
_materialTypes = value;
}
public function get materialTypes():ListCollectionView {
return _materialTypes;
}

public function set name(value:String):void {
_name = value;
}
public function get name():String {
return _name;
}

public function set unit(value:String):void {
_unit = value;
}
public function get unit():String {
return _unit;
}

public function readExternal(input:IDataInput):void {
__initialized = input.readObject() as Boolean;
__detachedState = input.readObject() as String;
if (meta::isInitialized()) {
_autoId = function(o:*):Number { return (o is Number ? o as Number : Number.NaN) } (input.readObject());
_materialType = input.readObject() as MaterialType;
_materialTypes = input.readObject() as ListCollectionView;
_name = input.readObject() as String;
_unit = input.readObject() as String;
}
else {
_autoId = function(o:*):Number { return (o is Number ? o as Number : Number.NaN) } (input.readObject());
}
}

public function writeExternal(output:IDataOutput):void {
output.writeObject(__initialized);
output.writeObject(__detachedState);
if (meta::isInitialized()) {
output.writeObject(_autoId);
output.writeObject(_materialType);
output.writeObject(_materialTypes);
output.writeObject(_name);
output.writeObject(_unit);
}
else {
output.writeObject(_autoId);
}
}
}
}

当调用远程服务返回的数据是一个ArrayCollection,包含所有的MaterialType的数据集合。

但是Tree的默认的dataDescriptor是查找children属性,可是MaterialType中没有,只有 materialTypes包含子node.

所以在mx.controls.treeClasses.DefaultDataDescriptor继承新类重载getChildren和 isBranch两个方法。

代码如下:

ActionScript代码

package org.bona.controls
{
import flash.utils.Dictionary;

import mx.collections.ArrayCollection;
import mx.collections.ICollectionView;
import mx.collections.XMLListCollection;
import mx.controls.treeClasses.DefaultDataDescriptor;
import mx.controls.treeClasses.ITreeDataDescriptor;

public class TreeDataDescriptor extends DefaultDataDescriptor implements ITreeDataDescriptor
{
/**
*  Constructor.
*/
public function TreeDataDescriptor(children:String=null)
{
super();
childrenField=children;
//trace(‘TreeDataDescriptor Constructor, ’ + childrenField);
}

/**
*  @private
*/
private var ChildCollectionCache:Dictionary=new Dictionary(true);

[Bindable]
public var childrenField:String=null;

override public function getChildren(node:Object, model:Object=null):ICollectionView
{
//          trace(node);
var childrenCollection:ICollectionView=super.getChildren(node, model);
var children:*;
if (childrenCollection != null)
{
//              trace(’super.getChildren =’, childrenCollection);
return childrenCollection;
}
children=node[childrenField];
//          trace(children);

//then wrap children in ICollectionView if necessary
if (children is ICollectionView)
{
childrenCollection=ICollectionView(children);
}
else if (children is Array)
{
var oldArrayCollection:ArrayCollection=ChildCollectionCache[node];
if (!oldArrayCollection)
{
childrenCollection=new ArrayCollection(children);
ChildCollectionCache[node]=childrenCollection;
}
else
{
childrenCollection=oldArrayCollection;
//ArrayCollection(childrenCollection).mx_internal::dispatchResetEvent=false;
ArrayCollection(childrenCollection).source=children;
}

}
else if (children is XMLList)
{
var oldXMLCollection:XMLListCollection=ChildCollectionCache[node];
if (!oldXMLCollection)
{
// double check since XML as dictionary keys is inconsistent
for (var p:*in ChildCollectionCache)
{
if (p === node)
{
oldXMLCollection=ChildCollectionCache[p];
break;
}
}
}

if (!oldXMLCollection)
{
childrenCollection=new XMLListCollection(children);
ChildCollectionCache[node]=childrenCollection;
}
else
{
childrenCollection=oldXMLCollection;

//We don’t want to send a RESET type of collectionChange event in this case.
//XMLListCollection(childrenCollection).mx_internal::dispatchResetEvent=false;
XMLListCollection(childrenCollection).source=children;
}
}
else
{
var childArray:Array=new Array(children);
if (childArray != null)
{
childrenCollection=new ArrayCollection(childArray);
}
}
return childrenCollection;
}

/**
*  Tests a node for termination.
*  Branches are non-terminating but are not required to have any leaf nodes.
*  If the node is XML, returns <code>true</code> if the node has children
*  or a <code>true isBranch</code> attribute.
*  If the node is an object, returns <code>true</code> if the node has a
*  (possibly empty) <code>children</code> field.
*
*  @param node The node object currently being evaluated.
*  @param model The collection that contains the node; ignored by this class.
*
*  @return <code>true</code> if this node is non-terminating.
*/
override public function isBranch(node:Object, model:Object=null):Boolean
{
var branch:Boolean = super.isBranch(node,model);
if (branch)return branch;
if (node == null)
return false;
if (node is Object)
{
try
{
if (node[childrenField] != undefined)
{
branch=true;
}
}
catch (e:Error)
{
}
}
return branch;
}

}

}

在应用程序模块中如下应用:

MXML代码


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:tdd="org.bona.controls.*" creationComplete="{initData();}" viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var datas:ArrayCollection = new ArrayCollection();
[Bindable]
private var selectedItem:MaterialType;

private function initData():void{
var mt:MaterialType = generateMaterialType(‘level top -1′);
generateMaterialType(‘level 2-1′,mt);
generateMaterialType(‘level 2-2′,mt);
generateMaterialType(‘level 2-3′,mt);
datas.addItem(mt);
mt = generateMaterialType(‘level top -2′);
datas.addItem(mt);
}

private function generateMaterialType(name:String,parent:MaterialType=null):MaterialType{
var mt :MaterialType = new MaterialType();
mt.name = name;
if(parent !=null){
if(parent.materialTypes==null){
parent.materialTypes = new ArrayCollection();
}
parent.materialTypes.addItem(mt);
}
return mt;
}

private function selected(e:Event):void{
selectedItem = Tree(e.target).selectedItem as MaterialType;
}

]]>
</mx:Script>
<mx:HDividedBox width="100%" height="100%">
<mx:Tree dataProvider="{datas}" labelField="name" height="100%" width="100%" change="selected(event);">
<mx:dataDescriptor>
<tdd:TreeDataDescriptor childrenField="materialTypes"/>
</mx:dataDescriptor>
</mx:Tree>
<mx:VBox width="100%" height="100%">
<mx:Label text="selected material type:"/>
<mx:TextArea width="100%" height="100%" text="{selectedItem.name}"/>
</mx:VBox>

</mx:HDividedBox>

</mx:Application>

这样就可以自定义childrenField来描述自己的结构。

查看在线Demo

JasperReport与JPA结合设计报表

最近思考采用JasperReport设计报表,用JPA技术填充报表后存放在服务端会话中(session),采用jasperReport XMLServlet分页返回XML给flex客户端。结合jasperReport flash viewer组件在客户端预览和打印报表。

前一博文中的案例是采用JDBC返回数据集给JasperReport,今天看到JasperReport的数据源可以是JavaBean Collection。于是想采用DAO返回数据集后给JRBeanDataSource,加上JPA的延迟加载技术就可以呈现报表。

一、JPA模型如下:

 

org.im.scm.domain.Material.java
  1. package org.im.scm.domain;  
  2.   
  3. import …  
  4.   
  5.   
  6. /** 
  7.  * Material entity. 
  8.  *  
  9.  * @author MyEclipse Persistence Tools 
  10.  */  
  11. //@Proxy(lazy = false)  
  12. @Entity  
  13. @Table(name = "Material", schema = "dbo", catalog = "imc_manager")  
  14. public class Material implements java.io.Serializable {  
  15.   
  16.     // Fields  
  17.   
  18.     private Integer autoid;  
  19.     private MaterialType materialType;  
  20.   
  21.     // Constructors  
  22.   
  23.     /** default constructor */  
  24.     public Material() {  
  25.     }  
  26.   
  27.     /** minimal constructor */  
  28.     public Material(Integer autoid) {  
  29.         this.autoid = autoid;  
  30.     }  
  31.   
  32.     /** full constructor */  
  33.     public Material(Integer autoid, MaterialType materialType) {  
  34.         this.autoid = autoid;  
  35.         this.materialType = materialType;  
  36.     }  
  37.   
  38.     // Property accessors  
  39.     @Id  
  40.     @Column(name = "autoid", unique = true, nullable = false)  
  41.     @GeneratedValue(strategy=GenerationType.IDENTITY)  
  42.     public Integer getAutoid() {  
  43.         return this.autoid;  
  44.     }  
  45.   
  46.     public void setAutoid(Integer autoid) {  
  47.         this.autoid = autoid;  
  48.     }  
  49.       
  50.     @ManyToOne(fetch=FetchType.LAZY)  
  51.     @JoinColumn(name = "materialTypeId")  
  52.     public MaterialType getMaterialType() {  
  53.         return this.materialType;  
  54.     }  
  55.   
  56.     public void setMaterialType(MaterialType materialType) {  
  57.         this.materialType = materialType;  
  58.     }  
  59.   
  60. }  

 

Java代码:org.im.scm.domain.MaterialType
  1. package org.im.scm.domain;  
  2.   
  3. import …  
  4.   
  5. /** 
  6.  * MaterialType entity. 
  7.  *  
  8.  * @author MyEclipse Persistence Tools 
  9.  */  
  10. @Entity  
  11. @Table(name = "materialType", schema = "dbo", catalog = "imc_manager")  
  12. public class MaterialType implements java.io.Serializable {  
  13.   
  14.     // Fields  
  15.   
  16.     private Integer autoId;  
  17.     private String name;  
  18.     private String type;  
  19.     private Set<Material> materials = new HashSet<Material>(0);  
  20.   
  21.     // Constructors  
  22.   
  23.     /** default constructor */  
  24.     public MaterialType() {  
  25.     }  
  26.   
  27.     /** minimal constructor */  
  28.     public MaterialType(Integer autoId, String type) {  
  29.         this.autoId = autoId;  
  30.         this.type = type;  
  31.     }  
  32.   
  33.     /** full constructor */  
  34.     public MaterialType(Integer autoId, String name, String type,  
  35.             Set<Material> materials) {  
  36.         this.autoId = autoId;  
  37.         this.name = name;  
  38.         this.type = type;  
  39.         this.materials = materials;  
  40.     }  
  41.   
  42.     // Property accessors  
  43.     @Id  
  44.     @Column(name = "autoId", unique = true, nullable = false)  
  45.     @GeneratedValue(strategy=GenerationType.IDENTITY)  
  46.     public Integer getAutoId() {  
  47.         return this.autoId;  
  48.     }  
  49.   
  50.     public void setAutoId(Integer autoId) {  
  51.         this.autoId = autoId;  
  52.     }  
  53.   
  54.     @Column(name = "name", length = 40)  
  55.     public String getName() {  
  56.         return this.name;  
  57.     }  
  58.   
  59.     public void setName(String name) {  
  60.         this.name = name;  
  61.     }  
  62.   
  63.     @Column(name = "type", nullable = false, length = 2)  
  64.     public String getType() {  
  65.         return this.type;  
  66.     }  
  67.   
  68.     public void setType(String type) {  
  69.         this.type = type;  
  70.     }  
  71.   
  72.     @OneToMany(cascade = CascadeType.ALL, mappedBy = "materialType", fetch = FetchType.LAZY)  
  73.     @OrderBy  
  74.     public Set<Material> getMaterials() {  
  75.         return this.materials;  
  76.     }  
  77.   
  78.     public void setMaterials(Set<Material> materials) {  
  79.         this.materials = materials;  
  80.     }  
  81.   
  82. }  

二、在应用服务中调用org.im.scm.domain.MaterialDAO.findAll();

 

Java代码
  1. private JRDataSource getJRDataSource(){  
  2.         JRBeanCollectionDataSource s= new JRBeanCollectionDataSource(materialDao.findAll());   
  3.         return s;  
  4.     }  

三、报表设置如下图:

建立字段autoId 类型为java.lang.Integer,字段materialType 类型为org.im.scm.domain.MaterialType;

在report属性"import"中导入"org.im.scm.domain.*",不然在服务中无法编译为Jasper文件,系统也不会提示出错,这个我也搞不明白。

四、服务器运行结果如下

 

用Python调用中控SDK存取考勤机数据库

开发环境:myeclipse 6.5,pyDev,Python 2.6,Python ex for windows,pymssql,中控SDK

主代码
  1. # -*- coding: utf-8 -*-  
  2.   
  3. ”’ 
  4. Created on Sep 17, 2009 
  5.  
  6. @author: sy 
  7. ”’  
  8. from win32com.client import Dispatch  
  9. from zk.demo.IC_db import IC_DB  
  10. import sys  
  11. from datetime import datetime  
  12.   
  13.   
  14.        
  15. devid = 1  
  16. usersInfo=[  
  17.            ['204113386','a1',3],  
  18.            ['-491435564','a2',4],  
  19.            ['1550229372','a3',5]  
  20.            ]  
  21. statusNames =(  
  22.               ‘Tatal adminstrator’,  
  23.               ‘Total users’,  
  24.               ‘Total FP’,  
  25.               ‘Total Password’,  
  26.               ‘Total manage record’,  
  27.               ‘Total In and out record’,  
  28.               ‘Nominal FP number’,  
  29.               ‘Nominal user number’,  
  30.               ‘Nominal In and out record number’,  
  31.               ‘Remain FP number’,  
  32.               ‘Remain user number’,  
  33.               ‘Remain In and out record number’)  
  34.   
  35. def syncDateTime(zk):  
  36.     print ‘Set Termail Datetime by PC…’  
  37.     if zk.SetDeviceTime(devid):  
  38.         print ‘Set Termail Datetime ok’  
  39.   
  40.       
  41.       
  42.         
  43. def SendUserInfo(zk):  
  44.     cardNo = ’0522766478′  
  45.     zk.SetStrCardNumber(cardNo)  
  46.       
  47.     zk.SetUserInfo(devid,2,‘沈阳’,None,True)  
  48.       
  49.     for user in usersInfo:  
  50.         print user  
  51.         zk.SetStrCardNumber(user[0])  
  52.         s = zk.SetUserInfo(devid,user[2],user[1],None,0,True)  
  53.         if s:  
  54.             print ‘send user %s info to device,Card No:%s ’ %(user[1],user[0])  
  55.     db = IC_DB()  
  56.     users = db.getUserInfo()  
  57.     usersCount = len(users)  
  58.       
  59.     if usersCount>0:  
  60.         print ‘Sending some user info to device…’, datetime.now()  
  61.         #zk.BeginBatchUpdate(devid,1)  
  62.         for user in users:  
  63.             zk.SetStrCardNumber(user[1])  
  64.             s = zk.SetUserInfo(devid,user[0],user[2],None,0,True)  
  65.             if s and usersCount<10:  
  66.                 print ‘send user %s info to device,Card No:%s ’ %(user[2],user[0])  
  67.         #if len(users)>0:  
  68.         #if zk.BatchUpdate(devid):  
  69.         print ‘Send %d user info to device.’ %(len(users)),datetime.now()  
  70. def downloadLog(zk):  
  71.     if zk.ReadAllGLogData(devid):  
  72.         print ‘User log list:’  
  73.         while True:  
  74.             s= zk.GetGeneralLogDataStr(devid,None,None,None,None)  
  75.             if s[0]:  
  76.                 print ‘Reg No:%d  VerifyMode:%d InOutMode:%d DateTime:%s’ %(s[1],s[2],s[3],s[4])  
  77.             else:  
  78.                 break  
  79.         print ‘User log list end.’  
  80.       
  81. def readDeviceStatus(zk):  
  82.     s = zk.GetFirmwareVersion(devid,None)  
  83.     if s[0]:  
  84.         print ‘firmware Version:’,s[1]  
  85.     s = zk.GetSerialNumber(devid,None)  
  86.     if s[0]:  
  87.         print ‘Serial Number:%s’ %(s[1])  
  88.     s = zk.GetProductCode(devid,None)  
  89.     if s[0]:  
  90.         print ‘Product Code:%s’ %(s[1])  
  91.     s= zk.GetDeviceTime(devid,None,None,None,None,None,None)  
  92.     if s[0]:  
  93.         print ‘Device Time:’ ,(s[1:8])  
  94.     for i in range(1,12):  
  95.         s= zk.GetDeviceStatus(devid,i,None)  
  96.         if s[0]:  
  97.             print ‘%s:%s’ %(statusNames[i-1],s[1])  
  98.       
  99.   
  100. def connectToZK(zk):  
  101.     devPort = 4370  
  102.     devIPAddr = ’192.168.30.198′  
  103.       
  104.     flag = zk.Connect_Net(devIPAddr,devPort)  
  105.     print ‘Connect flag:%d’ %flag  
  106.     if flag:  
  107.         print ‘Device Connected.’  
  108.     return flag  
  109.       
  110. def clearAllData(zk):  
  111.     print ‘Clear device all log..’  
  112.     if zk.ClearKeeperData(devid):  
  113.         print ‘Clear device all log finished.’  
  114.   
  115. def main():  
  116.       
  117.     zk = Dispatch(‘zkemkeeper.ZKEM’)  
  118.       
  119.     #sdkVersion = create_string_buffer(”,256)  
  120.     sdkVersion = zk.GetSDKVersion(None)  
  121.     if sdkVersion[0]:  
  122.         print ‘sdkVersion:’ , sdkVersion[1]  
  123.         if connectToZK(zk):  
  124.             readDeviceStatus(zk)  
  125.             syncDateTime(zk)  
  126.             if len(sys.argv)>1:  
  127.                 if sys.argv[1] ==‘send’:  
  128.                     clearAllData(zk)  
  129.                     SendUserInfo(zk)  
  130.             else:  
  131.                 downloadLog(zk)  
  132.             pass  
  133.             zk.Disconnect()  
  134.             print ‘Disconnect…’  
  135.     print ‘Done’  
  136.       
  137.       
  138.   
  139.    
  140. if __name__ == ‘__main__’:  
  141.     main()  

 

zk.demo.IC_db代码
  1. # -*- coding: utf-8 -*-  
  2. ”’ 
  3. Created on Sep 18, 2009 
  4.  
  5. @author: sy 
  6. ”’  
  7. import pymssql  
  8.   
  9. class IC_DB:  
  10.     ”’ 
  11.     classdocs 
  12.     ”’  
  13.     
  14.   
  15.     def __init__(self):  
  16.         ”’ 
  17.         Constructor 
  18.         ”’  
  19.            
  20.     def getUserInfo(self):  
  21.         con = pymssql.connect(host=‘localhost,1433′, user=‘sa’, password=,database =‘IC_DB’)  
  22.         cur = con.cursor()  
  23.         cur.execute(operation=’Select top 5 a.card_id,a.snr,b.user_name ,b.user_code FROM ztx_card_init a ,pub_user b,pub_card c\  
  24.                 Where a.card_id = c.Card_id1 AND c.User_uid = b.user_uid’)  
  25.         return cur.fetchall()  
  26.           
  27.           

 

转发-最新MyEclipse 7.5 插件安装方法

最新版MyEclipse 7.0正式版与以前的版本有很大不同,包括MyEclipse 7.0M2在内的老版本都是myeclipse快捷方式调用elipse.exe附加MyEclipse的JRE。而正式版7.0不再调用 eclipse.exe,而且在安装好的目录下面也没有了eclipse.exe。完全与myeclipse.exe被整合到一起了
    插件的安装当然可以通过eclipse自动升级,输入网址然后搜索自动安装插件,但是个人喜欢把插件放到一个统一的文件夹下,然后link进去,这样感觉比较的清爽,删除也很方便只需删掉link文件
  以前可以通过在eclipse的目录下面建一个links文件夹,再在下面建一个.link文件的方式安装插件,现在似乎不行了,直接放到plugins文件夹下面也不可用。安装方式有些变化,直接放到plugins下面可以参考下面的相对路径配置。

 

  目前安装插件的最简单方式是在myeclipse安装目录下的configuration\org.eclipse.equinox.simpleconfigurator目录下面的bundles.info文件里面按照格式添加插件信息如:

要求格式:包名,版本号,文件路经,4,false(后面两项不改,我也不知道是啥)

绝对路径方式:(这是添加的resourcebundle插件,资源文件编辑器)

com.essiembre.eclipse.i18n.resourcebundle,0.7.7,file:/D:\work\plugins\com.essiembre.eclipse.i18n.resourcebundle_0.7.7,4,false

可以使用绝对路径和相对路径。

相对路径方式:

  把插件复制到C:\Users\Gary\AppData\Local\Genuitec\Common\plugins文件夹下,不同操作系统位置可能有些不同,而且在安装的时候是可以选在路经的,在上面提到的bundles.info文件添加:

com.essiembre.eclipse.i18n.resourcebundle,0.7.7,file:plugins\com.essiembre.eclipse.i18n.resourcebundle_0.7.7,4,false

Spring Tool Suite开始支持OSGi

近日SpringSource开发团队发布了SpringSource Tool Suite 2.1.0 RC1版,该版本将支持与Amazon EC2及VMware工具的运行时集成。

凭 借SpringSource Tool Suite,我们可以将Spring应用打包并部署到SpringSource dm Server所提供的模块化OSGi运行时环境中。STS还集成了一个面向任务的用户界面以加速开发,一些架构评审工具以指导开发者遵循最佳实践以及运行 时错误分析工具,该工具能够自动定位错误进而帮助开发者解决运行中的应用所出现的问题。

过去SpringSource Tool Suite是个商业工具,然而SpringSource的创建者Rod Johnson在今年4月的SpringOne欧洲大会上宣布他们将免费发布STS suite。近日Christian Dupuis就该声明以及最新版本所提供的新特性专门撰写了一篇文章进行深入探讨。

SpringSource Tool Suite 2.1.0 RC1及最近的里程碑版的新特性列举如下:

开发工具

Spring项目特性:

新 的Spring Bean Definition和Web Flow Definition文件向导可以自动将Spring项目特性增加到新的项目中。其他的可视化工具如项目创建向导、基于表单的Spring配置文件编辑 器、快速修复与快速辅助、Bean创建向导及命名空间配置对话框也都有助于构建基于Spring的应用。

项目模板:

新 版本含有几个项目模板以帮助开发者快速构建新的Spring项目。这些项目模板包含了对Spring Portfolio项目的支持,如Spring MVC、Spring Web Flow、Spring Faces、Spring Batch及Spring Roo,还有对SpringSource dm Server的OSGi Bundle的支持。

类型感知的Bean引用内容的支持

STS 2.1.0 M2中增加了人们长久以来一直期望的一个特性:对Spring bean引用的内容辅助现在将优先选择与属性或构造方法参数类型一致的那些bean,与之匹配的bean将具有更高的优先级,同时会单独列在内容辅助提示UI中。

Spring 3.0 M3支持:

STS 已经进行了升级,内部将使用Spring Framework 3.0.0.M3以充分利用Spring 3.0的特性。新的命名空间<task:* />与<jdbc:* />已经集成到了STS中,就像Spring的其他命名空间一样,新的命名空间也具备内容辅助、链接和验证特性。STS还支持Spring 3.0新增的注解@Configuration和@Bean。我们可以在Spring Explorer和Dependency Graph中看到由@Bean所配置的Spring bean,还可以在Spring XML中引用这些bean。这些新注解还被添加到了STS的Stereotype和Annotation Grouping Support中,以支持配置类导航和验证。

Spring Roo集成:

现在开发者可以 单独安装Roo,然后将其配置到STS中而无需将二者打包在一起。这样我们就可以在将Roo及插件替换成新版本的同时又继续使用原来的STS了。为了充分 利用Spring Roo的优势,STS集成了Roo Shell并提供了Roo命令的快捷键(CTRL+R,Mac系统的快捷键是CMD+R)。我们可以在项目或是工作区层次上配置Roo的信息,这样同一工 作区的不同项目就可以使用不同版本的Roo和不同的插件。

Spring Batch可视化编辑器:

新 版STS对Spring Batch的可视化编辑器进行了一些改进以支持更多的编辑功能。要想访问该编辑器,请使用Spring Config Editor打开一个Spring XML bean定义文件(里面有Batch jobs)并选择batch-graph标签。

OSGi开发:

现 在Java开发者可以使用相应的工具查看、打包并部署模块化应用到SpringSource dm Server中。STS 2.0所提供的OSGi开发工具可以对Bundlor template.mf文件、MANIFEST.MF及TEST.MF manifest文件进行验证。

运行时集成工具

tc Server Instance及Group管理

新 版STS可以在IDE内部管理Group和单实例的tc Server。该版本扩展了STS 2.0.2所引入的tc Server集成特性,可以启动及关闭服务器,还可以在SpringSource AMS所管理的tc Server实例上进行远程应用部署。要想在STS中配置Group或单实例的tc Server,请开启WTP Servers视图并创建一个新服务器。在新建服务器向导中选择SpringSource AMS server类型并点击完成。

Amazon EC2集成

凭 借STS,我们可以将WAR应用、OSGi bundle及PAR项目部署到运行在Amazon EC2云上的dm和tc Server上。SpringSource已经发布了针对dm和tc Server的AMI。EC2集成会自动处理应用服务器集群的创建,如若需要还会进行负载均衡处理。

VMware Lab Manager:

STS 中还有一个名为“Lab Manager”的视图,开发者可以凭借该视图连接到VMware Lab Manager上并浏览配置信息。用户可以启动或停止相关配置,还可以在IDE中打开VM实例的控制台。我们可以从VMware Eclipse更新站点安装该特性。现在在虚拟数据中心部署Spring应用的开发者们拥有了相关的工具以对运行在VMware Workstation中的应用进行测试和调试。

新版的SpringSource Tool Suite还对刚发布的Eclipse 3.5提供了极佳的集成。近日Christian Dupuis和Adam Fitzgerald撰写了一篇文章,谈到了如何在Eclipse 3.5 Galileo中安装SpringSource Tool Suite 2.1.0.RC1 Eclipse插件。

从团队协作和任务管理的角度来看,STS(经过TaskTop认证的工具)扩展了Mylyn的面向任务的界面,提供了一个简单的工作流以简化现代企业项目复杂层次关系的导航。它对IDE中的所有编程元素及所访问的Web资源维护了一个浏览历史。