当前位置: 编程技术>移动开发
本页文章导读:
▪Java JNI例证(ubuntu) Java JNI例子(ubuntu)
1、创建HelloWorld.java
class HelloWorld {
public native void sayHello();
static {
System.loadLibrary("HelloWorld");
}
public static void main(String[] args) {
(new HelloWorld()).sayHello().........
▪ ubuntu安装jdk时出现install.sfx异常 ubuntu安装jdk时出现install.sfx错误
Install sun java 6 on Ubuntu 10.04||Ubunu10.04安装sun java6 Install sun java 6 on Ubuntu 10.04||Ubunu10.04安装sun java6 $ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"$ s.........
▪ 给listview平添一个页脚 给listview添加一个页脚
在ListView的最下面添加一个view视图:
private LayoutInflater inflater;
inflater=LayoutInflater.from(this);
view=inflater.inflate(R.layout.view, null);//自定义一个view
recoverlist.addFooterView(v.........
[1]Java JNI例证(ubuntu)
来源: 互联网 发布时间: 2014-02-18
Java JNI例子(ubuntu)
1、创建HelloWorld.java
class HelloWorld { public native void sayHello(); static { System.loadLibrary("HelloWorld"); } public static void main(String[] args) { (new HelloWorld()).sayHello(); } }
2、编译生成HelloWorld.class
root@meie:~/Desktop#javac HelloWorld.java
3、编译生成HelloWorld.h
root@meie:~/Desktop#javah HelloWorld
4、编译生成libHelloWorld.so(注意jdk参数指向)
root@meie:~/Desktop# gcc -shared -I /usr/lib/jvm/java-6-sun/include/ -I /usr/lib/jvm/java-6-sun/include/linux/ -I /usr/in clude/ HelloWorld.c -o libHelloWorld.so
5、创建HelloWorld.c文件
#include "jni.h" #include "HelloWorld.h" #include <stdio.h> JNIEXPORT void JNICALL Java_HelloWorld_sayHello (JNIEnv *env, jobject obj) { printf("Hello,the World!!!"); }
6、测试代码,成功
java -Djava.library.path=. HelloWorld
注意:直接用 java HelloWorld会报错
root@meie:~/Desktop# java HelloWorld Exception in thread "main" java.lang.UnsatisfiedLinkError: no HelloWorld in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734) at java.lang.Runtime.loadLibrary0(Runtime.java:823) at java.lang.System.loadLibrary(System.java:1028) at HelloWorld.<clinit>(HelloWorld.java:6) Could not find the main class: HelloWorld. Program will exit.
这时java文件中loadlib时找不到这个so导致的,我们这样来运行:"java -Djava.library.path=. HelloWorld",通过设置java.library.path来找到这个so。
[2] ubuntu安装jdk时出现install.sfx异常
来源: 互联网 发布时间: 2014-02-18
ubuntu安装jdk时出现install.sfx错误
Install sun java 6 on Ubuntu 10.04||Ubunu10.04安装sun java6
Install sun java 6 on Ubuntu 10.04||Ubunu10.04安装sun java6
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
$ sudo apt-get install sun-java6-jre
Install sun java 6 on Ubuntu 10.04||Ubunu10.04安装sun java6
Install sun java 6 on Ubuntu 10.04||Ubunu10.04安装sun java6
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
$ sudo apt-get install sun-java6-jre
[3] 给listview平添一个页脚
来源: 互联网 发布时间: 2014-02-18
给listview添加一个页脚
在ListView的最下面添加一个view视图:
private LayoutInflater inflater;
inflater=LayoutInflater.from(this);
view=inflater.inflate(R.layout.view, null);//自定义一个view
recoverlist.addFooterView(view);//TODO 添加footer,要注意这个调用必须在setadapter之前。recoverlist是一个ListView对象
最新技术文章: