java 调用dll文件
//1.创建testdll.java文件
public class testdll
{
static
{
System.loadLibrary("goodluck");
}
public native static int get();
public native static void set(int i);
public static void main(String[] args)
{
testdll test = new testdll();
test.set(10);
System.out.println(test.get());
}
}
//2.javac testdll.java
//3.javap testdll
//4.创建一个简单的VC DLL项目
//5.加入类路径(C:\Program Files\Java\jdk1.6.0_02\include,C:\Program Files\Java\jdk1.6.0_02\include\win32)到/tool/dectionary/ 下
//6.将testdll.h文件add file to folder
//7.在将#include "testdll.h"拷贝到StdAfx.h 文件的最后一行
//8.在testdll.cpp文件的最后一行加入
int i = 0;
JNIEXPORT jint JNICALL Java_testdll_get (JNIEnv *, jclass)
{
return i;
}
JNIEXPORT void JNICALL Java_testdll_set (JNIEnv *, jclass, jint j)
{
i = j+1;
}
//builder all
//将生成的 testdll.dll文件放在刚刚生成的class文件同一级目录
//java testdll 就可以看到结果了
相关文档:
Java NIO API详解
在JDK
1.4以前,Java的IO操作集中在java.io这个包中,是基于流的阻塞(blocking)API。对于大多数应用来说,这样的API使用很方
便,然而,一些对性能要求较高的应用,尤其是服务端应用,往往需要一个更为有效的方式来处理IO。从JDK 1.4起,NIO
API作为一个基于缓冲区,并能提供非阻塞(non-blo ......
.net代码如下,
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
// [System.Web.Script.Services.ScriptService]
public class SysService : System.Web.Services.Web ......
Java 和 C#的比较
1。访问控制方面:C#有public、internal、protected、private,比java多了个internal,其实它跟java的包访问差不多,internal表示同一个编译集合(如exe、dll)下的类可以互访。
对于protected,java和C#有区别。在java中,protected和包访问级别差不多,即不是私有的。而在C#中,protected和priv ......
一 相对路径的获得
说明:相对路径(即不写明时候到底相对谁)均可通过以下方式获得(不论是一般的java项目还是web项目)
String relativelyPath=System.getProperty("user.dir");
上述相对路径中,java项目中的 ......
package com.test.servlet;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.message.SOAPHeaderElement;
public class WebService {
&nbs ......