package ***does not exist!!!!!

iouzhui 2006-07-30 01:25:36
counter.java:5: package gbk does not exist
import gbk.*;
^
1 error

[code]
StringChange.java

package gbk;

public class StringChange {
public StringChange(){}
public static String convert( String str ) {
if (str.trim()==""){
return null;
}
try {
/**Encodes this String into a sequence of bytes using the named * charset,

storing the result into a new byte array.
*/
byte[] bytesStr=str.getBytes( "ISO-8859-1" ) ;
/**Constructs a new String by decoding the specified array of * bytes

using the specified charset. The length of the new String * is a function of the

charset, and hence may not be equal to
* the length of the byte array.
*/
return new String( bytesStr, "GBK" ) ;
}
catch( Exception ex ) {
return str ;
}
}
}

Counter.java

package count;

import java.lang.*;
import java.util.*;
import gbk.*;


public class Counter{
private int count = 0;
StringChange ITG = new StringChange();
private String ddd = new String("ComeOnBaby!");


public Counter(){
}

public void setCount(int i){
this.count = i;
}
public int getCount(){
count++;
return this.count;
}
public String getDdd(){
return ddd;
}
public void setDdd(String s ){
String ss = new String();
ss = ITG.convert(s);
this.ddd = ss;
}
}
...全文
736 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
iouzhui 2006-07-30
  • 打赏
  • 举报
回复
谢谢!
zebra007 2006-07-30
  • 打赏
  • 举报
回复
你的StringChange 和Counter类在不同的包里
编译后者时需要把前者的位置添加到classpath

而你gbk文件夹放到count下后,因为一般当前目录都被加进classpath,所以可以找到gbk了
yaray 2006-07-30
  • 打赏
  • 举报
回复
楼主不明白包的含义吧.

package com.yaray.tools;

public class MyTools {
...
}

如果你的工程是WEB工程: 需要将MyTools.java编译后的MyTools.class文件放置在WEB-INF/classes/com/yaray/tools目录下
iouzhui 2006-07-30
  • 打赏
  • 举报
回复
问题解决
原来是要把gbk文件夹放到count/下

不过一点不理解为什么要这样做??

希望大家帮忙!

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧