我知道用System.loadLibrary()加载动态库,但在applet中如何可以调用动态库?
解决方案 »
- jdbc 如何使用 Insert into Table2(field1,field2,...) select value1,value2,... fr
- 求解java 组合算法
- 大家看看我的倒排索引的文件组织方案,给点意见。
- ORA-03115: 不支持的网络数据类型或表示法错误
- A为什么不对,F为什么对?
- 急!POI 怎么读取合并后的单元格的数据?
- 100元求高手改java小程序,功能完善立即付费!
- java语言连数据库的问题
- 关于java.lang.NullPointerException
- 关于WebSphere3.0的问题
- 简单窗口位置问题
- 怎样把ByteBuffer型数据转换成Strin型数据
import java.awt.event.*;
import java.applet.*;/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/public class Applet1 extends Applet {
private boolean isStandalone = false;
private BorderLayout borderLayout1 = new BorderLayout();
private Button button1 = new Button();
private TextArea textArea1 = new TextArea();
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
} //Construct the applet
public Applet1() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
this.setLayout(borderLayout1);
button1.setLabel("button1");
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
}
});
textArea1.setText("textArea1");
this.add(button1, BorderLayout.NORTH);
this.add(textArea1, BorderLayout.CENTER);
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
} void button1_actionPerformed(ActionEvent e) {
String s1 = "";
try{
LocalMethodDemo lmd1 = new LocalMethodDemo();
// textArea1.setText(lmd1.msg);
s1 = lmd1.LocalMethod1();
textArea1.setText(s1); }
catch(Exception e1){
textArea1.setText(e1.getMessage()); }
}}
public class LocalMethodDemo {
public native static String LocalMethod1( );
public native static int LocalMethod2( );
public static String msg="";
static{
try{
System.loadLibrary("LocalMethodDemo");
}
catch(Exception e){
msg = e.getMessage();
}
}
public static void main(String[] args){
String sRet = ""; int iRet=0;
try{
System.out.println( "Call LocalMethod1" );
sRet = LocalMethod1( );
System.out.println( "Return:" + sRet );
System.out.println( "Call LocalMethod1 successfully :-)");
}
catch(Exception e){
System.out.println("Call LocalMethod1 failed :-(");
}
try{
System.out.println( "Call LocalMethod2" );
iRet = LocalMethod2( );
System.out.println("return = " + iRet );
System.out.println( "Call LocalMethod2 successfully :-)");
}
catch(Exception e){
System.out.println("Call LocalMethod2 failed :-(");
} }
}