2009年2月19日星期四

Java: Exception in thread main java.lang.NoClassDefFoundError

Common error that beginning java authors may experience.

    Exception in thread "main" java.lang.NoClassDefFoundError:

    You try to run a little java program and you get this blasted error. I first got this error when running our little hello world program.

    This occurs because the classpath is not setup or referenced correctly.

    Executing your program using this command should correct the problem:
    java -classpath . helloworld

    where helloworld is the name of your compiled class.

    This tells java that your classpath is your local directory.

http://www.tech-recipes.com/rx/826/java-exception-in-thread-main-javalangnoclassdeffounderror/
--
yaoms

2009年2月17日星期二

建行USBKey的NC问题--(windows XP下,使用非admin组用户登录的读不到证书。)

今天想为支付宝充值,却发现折腾半天支付的时候显示"尊敬的客户,请插入正确的USB KEY证书!"。还以为驱动程序又有问题(上次出过一次问题,不记得具体症状了,95533的技术人员让我重装USBKey的管理程序搞好的),就找出那张cd再卸载安装一遍(期间免不了重启电脑)。谁知这次问题没有解决,还是一样的提示。。。

琢磨半天突然想到我现在用的是一个受限用户,不会又让我遇到一个不考虑小用户的软件吧?立马切换过去,在打开3个窗口,点击4次链接,输入3组用户密码后,终于发现问题没有了。。。。

看来想要离开admin组躲下清静还真不容易。。


--
yaoms

2009年1月18日星期日

python 学习中遇到的问题

class a:
  def __init__(self):
    pass
class b(a):
  def __init__(self,name=None):
    a.__init__(self)
    self.name=name

在继承中,子类要覆盖父类的方法,这时调用父类的方法为什么必须加上self? python不是会自动加么?

str() 和  repr() 的区别?

is 关键字和 == 的区别。 a='hello';b=a;c=a[:];a is c; a is b; a==b; a==c??

2009年1月16日星期五

linux命令:镜像一个http站点

wget -m http://hostname/path

或者
lftp -c 'mirror -c http://hostname/path'

python 中的正则表达式模块 re

import re
p = re.compile(r', (\d{1,3})%')
if p.match('100% up, 23% down'):
    print 'ok'
print p.search('100% up, 23% down').groups()

python 中使用 sleep 函数

from time import sleep
sleep(10)

python 获取 shell 命令的输出

有两种方法。
一种是Popen:

import subprocess
output = subprocess.Popen(['ls','-l'],stdout=subprocess.PIPE,shell=True).communicate()
print output[0]

 
另外一种则可返回状态与调用的shell命令的输出结果

import commands
status, output = commands.getstatusoutput('ls -l')
 
Thanks to sin :)
-----
延伸:通过 dir(commands) 可以得知,实际上 有 getoutput 这个只获取输出的简单方法的。