Posts Tagged ‘Java’

2009/12/11

一、下载要用的 jad.exe 和插件包。

二、把 jad.exe 放到 jre 的 bin 目录下,把 net.sf.jadclipse_3.3.0.jar 放到 MyEclipse 6.5M1 Blue\eclipse\plugins 目录下。

三、打开 eclipse,然后 Windows——>Perference——>Java——>jadClipse,设置 path to decompiler 为 jad.exe 的全路径,如: \Java\jre1.5.0_06\bin\jad.exe,在 Directory for temporary files 中指定临时文件的路径,如: G:\Java\eclipse-SDK-3.0-win32\temp。

四、在 Eclipse 的 Windows——>Perference——>General->Editors->File Associations
    中修改“*.class”默认关联的编辑器为“JadClipse Class File Viewer”。

—-2009/05/27

Related posts

Tags: .

定义String对象的一个Trim属性方法,可以这样实现这个方法:

String.prototype.Trim = function()
     {
         return this.replace(/(^\s*)|(\s*$)/g,"");
     }

可以去掉一个字符串里前后的空格,这样一个字符串的变量就可以用到这个方法。

注:允许字符串间有空格的。

String:对象名称。prototype:增加属性。Trim:属性名称。

—-2008/12/19

Related posts

Tags: .
2009/02/26

因为毕业设计要用到jsp,这两天在准备着搭Java环境。下午把JDK装上,配置好path,classpath和java_home几个环境变量,然后随手用EmEditor中自带的Java模板自动生成了一个hello world函数,测试一下JDK是否装好。

代码,保存成hello.java
class Hello {
    public static void main(String args[])
    {
        System.out.println("Hello, world!");
    }
}

编译:javac hello.java,顺利通过,然后运行:java hello,报错:

错误信息:
Exception in thread "main" java.lang.NoClassDefFoundError:
……
Could not find the main class: hello.  Program will exit.

编译能通过,不能运行,这个报错生生折腾了我两个小时,起初以为是环境变量没设好,改了N次,仍然是报错,气得半死。Google的时候说Java严格区分大小写,就留心了一下,果然是这个问题。类名是calss Hello,大写,文件名却是hello.java,小写,编译的时候javac不区分大小写,所以编译通过,生成Hello.class文件,运行的时候却是java hello,与类名不符,进而could not find the main class,所以报错。

教训啊,一定要注意,Java里文件名要和main class类名完全一致,大小写严格区分。还有,写程序时候遇见错误一定要心平气和的去debug,越急躁越不行;也要注意写程序的细节问题,细节决定成败,真理啊!

Related posts

Tags: .