打个rar包的话,你最终还是要解开啊,用户只需将应用文件(jsp,class文件)拷贝到另外一台机子上就行了呀。

解决方案 »

  1.   

    首先不明白你为什么有这个要求。
    如果要达到这个目的,还是有办法的,比如在你的class里面判服务器的ip,如果不是授权ip就报错或者就启动认证程序要求输入注册码才将此ip授权。
    不过我总觉得这种要求就不是很合理的要求!而且还有用户不会去反编译class文件的前提!
      

  2.   

    不再灌水 说的方法可以达到你的要求,你在Servlet里面做一个判断,判断服务器的IP,如果IP不符合要求的就不允许运行。
      

  3.   

    绑定IP/网卡地址,先获取MAC地址import java.net.InetAddress;
    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里面绑定!不用多说了哦:)