打个rar包的话,你最终还是要解开啊,用户只需将应用文件(jsp,class文件)拷贝到另外一台机子上就行了呀。
解决方案 »
- 在线等,急。。。。。
- SOS 救命!java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]对象名 'person' 无效。
- 关于修改本机IP地址的问题,请教
- 如何建立一个树桩结构?
- 下载Crystal Enterprise Embedded Edition
- jsp页面调用servlet出错,帮莱鸟小弟侃侃。
- jsp如何将sessionID传给applet
- jsp的简单问题!如何将定义的变量插入到jsp代码中?
- tomcat下如何管理多个站点?
- CLOB保存到本地文件时,内存溢出
- bean之间调用为何不正确?[急]
- 高分求解决解悉xml的问题!!!!!
如果要达到这个目的,还是有办法的,比如在你的class里面判服务器的ip,如果不是授权ip就报错或者就启动认证程序要求输入注册码才将此ip授权。
不过我总觉得这种要求就不是很合理的要求!而且还有用户不会去反编译class文件的前提!
import java.io.InputStream;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.text.ParseException;
import java.util.StringTokenizer;import java.io.InputStreamReader;
import java.io.LineNumberReader;public class NetworkInfo
{
//get IP Address (only for winzk series OS)
public static String getMacAddress() throws IOException
{
String os = System.getProperty("os.name");
try
{
if (os.startsWith("Windows"))
{
return windowsParseMacAddress(windowsRunIpConfigCommand());
}
else
{
throw new IOException("unknown operating system: " + os);
}
}
catch (ParseException ex)
{
ex.printStackTrace();
throw new IOException(ex.getMessage());
}
}
public static void main(String[] args)
{
try
{
//System.out.println("UUID = " + NetworkInfo.getMacAddress());
System.out.println(getMacAddress("202.104.32.198"));
}
catch( Exception e )
{
System.out.println(e);
}
}
private final static String windowsParseMacAddress(String ipConfigResponse) throws ParseException
{
String localHost = null;
try
{
localHost = InetAddress.getLocalHost().getHostAddress();
//System.out.println(localHost);
}
catch (java.net.UnknownHostException ex)
{
ex.printStackTrace();
throw new ParseException(ex.getMessage(), 0);
}
/* StringTokenizer
* public StringTokenizer(String str,String delim, boolean returnTokens);
* public StringTokenizer(String str, String delim);
* public StringTokenizer(String str);
*/ StringTokenizer tokenizer = new StringTokenizer(ipConfigResponse, "\n");
String lastMacAddress = null;
//判断字符串中是否还有token
while (tokenizer.hasMoreTokens())
{
String line = tokenizer.nextToken().trim();
// see if line contains IP address
if (line.endsWith(localHost) && lastMacAddress != null)
{
System.out.println( "MAC_Address = " + lastMacAddress );
System.out.println( "IPA_ddress = " + localHost );
return lastMacAddress;
}
// see if line contains MAC address
int macAddressPosition = line.indexOf(":");
if (macAddressPosition <= 0)
continue;
String macAddressCandidate = line.substring(macAddressPosition + 1).trim();
//System.out.println(macAddressCandidate);
if (windowsIsMacAddress(macAddressCandidate))
{
lastMacAddress = macAddressCandidate;
continue;
}
}
ParseException ex = new ParseException("cannot read MAC address from [" + ipConfigResponse + "]", 0);
ex.printStackTrace();
throw ex;
}
private final static boolean windowsIsMacAddress(String macAddressCandidate)
{
// TODO: use a smart regular expression
if (macAddressCandidate.length() != 17)
return false;
return true;
}
private final static String windowsRunIpConfigCommand() throws IOException
{
//run the command "ipconfig /all" in order to get the MAC INFO;
Process p = Runtime.getRuntime().exec("ipconfig /all");
InputStream stdoutStream = new BufferedInputStream(p.getInputStream());
StringBuffer buffer= new StringBuffer();
for (;;)
{
int c = stdoutStream.read();
if (c == -1)
break;
buffer.append((char)c);
}
String outputText = new String((buffer.toString().getBytes("ISO8859_1")), "GB2312");
stdoutStream.close();
System.out.println("outputText = " + outputText );
return outputText;
}
private final static String getMacAddress(String remotePcIP)
{
String str="";
String macAddress="";
try
{
Process pp= Runtime.getRuntime().exec ("nbtstat -A " + remotePcIP);
InputStreamReader ir = new InputStreamReader(pp.getInputStream());
LineNumberReader input = new LineNumberReader (ir);
for (int i = 1; i <100; i++)
{
str=input.readLine();
if (str!=null)
{
if(str.indexOf("MAC Address")>1)
{
macAddress=str.substring(str.indexOf("MAC Address")+14,str.length());
break;
}
}
}
}
catch (IOException ex)
{
}
return macAddress;
}
}
然后在servlet里面绑定!不用多说了哦:)