Atitit. 木馬病毒的外部class自動載入機制------載入class的方法總結,atitit.------

來源:互聯網
上載者:User

Atitit. 木馬病毒的外部class自動載入機制------載入class的方法總結,atitit.------

Atitit. 木馬病毒的外部class自動載入機制------載入class的方法總結

Atitit.java load class methods

 

1. 動態載入jar檔案和class檔案。 1

2.  使用Class靜態方法 Class.forName  1

2.1. 使用ClassLoader  1

2.2. 3. 直接new  2

3. Ref 2

 

1. 動態載入jar檔案和class檔案。

完成上述兩步操作後,即可使用Class.forName來載入jar中或.class檔案包含的Java類了。

 

2.  使用Class靜態方法 Class.forName  



    Class cls = Class.forName("com.rain.B"); 
    B b = (B)cls.newInstance(); 

2. 

作者:: 綽號:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿爾 拉帕努伊 ) 漢字名:艾龍,  EMAIL:1466519819@qq.com

轉載請註明來源: http://www.cnblogs.com/attilax/

 

2.1. 使用ClassLoader  


    /* Step 1. Get ClassLoader */ 
    ClassLoader cl; // 如何獲得ClassLoader參考1.6 

    /* Step 2. Load the class */ 
    Class cls = cl.loadClass("com.rain.B"); // 使用第一步得到的ClassLoader來載入B 
     
    /* Step 3. new instance */ 
    B b = (B)cls.newInstance(); // 有B的類得到一個B的執行個體 

2.2. 3. 直接new  


    B b = new B();

1.

3. Ref 

 

ClassLoader 詳解及用途(寫的不錯)-mcuflower-ChinaUnix部落格.htm

 

Java中動態載入jar檔案和class檔案 - - 部落格頻道 - CSDN.NET.htm

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.