java war包 加密_一个java加密引起的问题

最近我在IBM的技术网站上下了一个用DWR来简化AJAX在java平台上应用的例子。具体可以到他的网站上去下载这个包。下完解压后,由于小弟不才,直接用拷贝粘贴的方式建好了web目录,并将该目录放在Tomact的webapps下。一切就绪后,运行猫。等啊等,好了。界面出来了,接下来就点搜索按纽,没有出来预想的结果,倒弹出来了一个错误框,说什么找不到类什么的错误。什么原因呢,我百思不得其解,都是拷贝粘贴啊,不应该有错的。难道是目录成次有问题?我想了好半天,头都想破了,也没则。后来我又看见原解压目录有个build.xml的文件,而且还有个说明文档,说可以用它来建web,虽然我不会用这个,可是还是在Eclipse下硬着头皮做了一个。(是按我自己的 理解做的,呵呵,可想而知结果)陷入了僵局的我抓耳捞腮。最后又到解压目录下,看有没有什么线索。哎,好象还有一个dwr-app.war这么个文件,这是什么东东啊(大家不要笑,我可是出学者,想必大家才开始学的时候也有这样的经历)。到google搜了一搜它的扩展名,结果都是战争一类的,风马牛不相及。于是加了全部的名字去搜dwr-app.war,靠,竟然没有结果,好痛苦啊。于是用了app.war去搜,好,有结果了。看了一看。其中有一篇说可以将该文件放在tomcat下,然后从起猫。它会自动在tomcat的webapps下建立好目录。真的吗,带着疑虑我照他的作了,死马当活马医吧,反正也没其他方法了。一切作好后,我将目录转到webapps下,然后启动猫。眼睛死死盯着屏幕,等待奇迹的发生。哈哈,果然象他说的那样,产生的一个目录。打开一看什么文件都建好了。还有这等好事,我以前咋不知道呢(大伙又要笑了,小菜鸟啊)。这个目录的能跑吗,带着这个疑问,我打开网页,键入地址。页面出来了,按一下按钮,结果出来了。好高兴啊。。。。可是我的那个拷贝为什么不能跑呢?为了找原因,于是我又开始了一个最愚蠢的做法,一个一个文件比对。jar, html,js,xml,都有啊,而且位置都一样啊。我感到很诡异。我想今天我要找不到原因,我就不睡觉了(嘿嘿,钻牛角尖了)。真不行,我一个一个文件的替换。(好惨,这就是一个初级菜鸟的学习之路,好艰辛啊,55555,不知大家也是不是这样练成大虾的,是的话,我就心安了,否则。。。)接下来,就是纯体力劳动,停猫,换文件,起猫,开网页,还要删除猫下的缓存。这一趟跑下来,把我弄的头晕眼花。眼看文件都快替换完了,最后只剩下class目录下了,这时我真的想放弃了,按理说(其实是我的想法)class文件都是死的,怎么可能不一样呢,换了也没用。进目录看了一下,如我想的一样,就那几个文件,名字也一样啊,真搞不懂。但是还是没放弃替换,把class目录一起拷过去,替换。本来是不报希望的,可是就是在失望之时给你惊喜,列表竟乖乖的出来了。啊,怎么是这样呢?用反编译软件打开两个class文件进行比较。那个从war自动生成的class文件有很完整的内容,如下:

package developerworks.ajax.store;

import java.util.*;

// Referenced classes of package developerworks.ajax.store:

// CatalogueDAO, Item, Utils

public class Cart

{

public Cart()

{

totalPrice = 0;

contents = new HashMap();

}

public Cart addItemToCart(String itemId)

{

Item item = (new CatalogueDAO()).getItem(itemId);

if(item != null)

{

totalPrice += item.getPrice();

int newQuantity = 1;

Integer oldQuantity = (Integer)contents.get(item);

if(oldQuantity != null)

newQuantity += oldQuantity.intValue();

contents.put(item, new Integer(newQuantity));

}

return this;

}

public Cart getCart()

{

return this;

}

public int getTotalPrice()

{

return totalPrice;

}

public String getFormattedTotalPrice()

{

return Utils.formatCurrency(totalPrice);

}

public Map getSimpleContents()

{

Map simpleContents = new HashMap();

Item item;

for(Iterator I = contents.keySet().iterator(); I.hasNext(); simpleContents.put(item.getName(), contents.get(item)))

item = (Item)I.next();

return simpleContents;

}

private Map contents;

private int totalPrice;

}

而我拷贝的class文件却是这样的:

package developerworks.ajax.store;

public class Cart

{

public Cart()

{

throw new Error("Unresolved compilation problems: \n\tThe type Map is not generic; it cannot be parameterized with arguments \n\tSyntax error, parameterized types are only available if source level is 5.0\n\tcontents cannot be resolved\n\tThe type HashMap is not generic; it cannot be parameterized with arguments \n\tSyntax error, parameterized types are only available if source level is 5.0\n\tcontents cannot be resolved\n\tcontents cannot be resolved\n\tThe type Map is not generic; it cannot be parameterized with arguments \n\tSyntax error, parameterized types are only available if source level is 5.0\n\tThe type Map is not generic; it cannot be parameterized with arguments \n\tSyntax error, parameterized types are only available if source level is 5.0\n\tThe type HashMap is not generic; it cannot be parameterized with arguments \n\tSyntax error, parameterized types are only available if source level is 5.0\n\tThe type Iterator is not generic; it cannot be parameterized with arguments \n\tSyntax error, parameterized types are only available if source level is 5.0\n\tcontents cannot be resolved\n\tcontents cannot be resolved\n");

}

public Cart addItemToCart(String itemId)

{

throw new Error("Unresolved compilation problems: \n\tcontents cannot be resolved\n\tcontents cannot be resolved\n");

}

public Cart getCart()

{

throw new Error("Unresolved compilation problem: \n");

}

public int getTotalPrice()

{

throw new Error("Unresolved compilation problem: \n");

}

public String getFormattedTotalPrice()

{

throw new Error("Unresolved compilation problem: \n");

}

private int totalPrice;

}

而在html中弹出的也正是上面的Error。我的第一反映就是加了密了。以前也听说过什么加密,防止反编译。可是没想到今天让我这个菜鸟给遇上了。其实我想如果是个大虾,也许根本不遇不到这个问题,因为他直接就build 或者用war文件来建,(或许还有更好的方法,有的话在回复时能告诉小弟)。可是就是我这个菜鸟,而且用了拷贝粘帖方法的菜鸟给遇上了。好了,问题解决了,我的文章也快完了。

大家在看完了这篇文章后感觉这写的是什么吗,一点技术含量都没有,是的,可是就是这些没有一点技术含量的问题,却成为我们这些初学者最大的拌脚石,很多人可能就是因为这些小问题而对java望而却步,不再对java深入研究。其实,本身不在于问题是否简单,而在于问题是不是给你造成了障碍,让你无法继续进行研究,这也是我发表这篇文章的目的。如何帮助我们初学者扫清障碍,让我们度过这个难关,有更多时间来学习技术,而不是找一些低级错误。

所以我希望各位大虾在看完我的文章,笑的捧腹之余,也能理解我们这些菜鸟的无奈。最好是多写一些经验性的文章,也就不枉我这么多口舌在这边老老叨叨了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值