「java调用dl」java调用dll找不到指定模块

博主:adminadmin 2022-12-01 18:35:10 77

今天给各位分享java调用dl的知识,其中也会对java调用dll找不到指定模块进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

java之如何实现调用启动一个可执行文件,exe

1. 从获得一个TowerJ编译器,该编译器可以将你的CLASS文件编译成EXE文件。

2. 利用微软的SDK-Java 4.0所提供的jexegen.exe创建EXE文件,这个软件可以从微软的网站免费下载,地址如下:

jexegen的语法如下:

jexegen /OUT:exe_file_name

/MAIN:main_class_name main_class_file_name.class

[and other classes]

3. Visual Cafe提供了一个能够创建EXE文件的本地编译器。你需要安装该光盘上提供的EXE组件。

4. 使用InstallAnywhere创建安装盘。

5. 使用IBM AlphaWorks提供的一个高性能Java编译器,该编译器可以从下面的地址获得:

6. JET是一个优秀的Java语言本地编译器。该编译器可以从这个网站获得一个测试版本:

7. Instantiations公司的JOVE

JOVE公司合并了以前的SuperCede,一个优秀的本地编译器,现在SuperCede已经不复存在了。

8. JToEXE

Bravo Zulu Consulting, Inc开发的一款本地编译器,本来可以从该公司的网页上免费下载的,不过目前在该公司的主页上找不到了。

java怎么使用dll中返回值为handle谢谢了,大神帮忙啊

这几天因为项目需要,用到了java调用dll文件中的方法。写成dll文件大多是用C、VB、Delphi语言弄成的,对于我这个纯粹干java的人员来说,着实让我太为难了。唉,也就是说我编程底子没有搭好,惭愧。要是这些语言我都会些,也不至少让我了解并应用这个技术花了很长时间。 我是用JNative技术做的一个例子。需要用到的是:JNative.jar,JNative.dll这些是在Windows中开发的,如果用Linus要用到libJNative.so 1.将JNative.dl,所要读的dll文件l放在C:\windows\system32下面。 2.将JNative.jar放在你的项目下的lib下面 3.将要读的dll文件放在跟使用的类相同的目录下。 4.我的类的源码 package sms; import org.xvolks.jnative.JNative; import org.xvolks.jnative.exceptions.NativeException; import org.xvolks.jnative.misc.basicStructures.AbstractBasicData; import org.xvolks.jnative.pointers.Pointer; import org.xvolks.jnative.pointers.memory.MemoryBlockFactory; public class SystemTime extends AbstractBasicDataSystemTime{ public short wYear; public short wMonth; public short wDayOfWeek; public short wDay; public short wHour; public short wMinute; public short wSecond; public short wMilliseconds;

java代码如何调用DL-888B打印机打印条形码

要是用打印机打印条形码的话,也可以不用Java代码的,除非你是这方面的专业的人员,要不这个还真搞不来,我一般打印条形码用的是一个条形码打印软件,它用的是哪种通用驱动,几乎对所有的打印机都能了连接打印的。

在这个软件里面绘制条形码,然后添加内容,并打印出来,而且现在专业的条形码打印软件支持多种类型的数据库导入,可以实现那种有多少个条码数据都能一次生成,而且可以批量打印出来,非常的方便。

上面这个是点击数据库设置可以导入那种TXT、Excel、access等很多种格式的文档,下面在添加条形码内容时,用数据库导入的方式添加,添加后直接点击预览,就能看到所有的数据按照Excel里面的顺序自动生成在每个标签上,就可以一次性打印出来所有的条形码啦

java程序如何调用Graphviz

网上有别人已经写好的一个GraphViz.java类。java可以直接调用这个类实现画图功能,但是使用这个类的前提是你的电脑已经装了GraphViz软件,你可以在下载windows版本,装完后,找到dot.exe所在的路径,我电脑上的是D:\Program Files\Graphviz2.30\bin\dot.exe,

将GraphViz.java中的这一路径改成你电脑上的路径,基本上就可以用了。

package Graphoutput;

// GraphViz.java - a simple API to call dot from Java programs

/*$Id$*/

/*

******************************************************************************

* *

* (c) Copyright 2003 Laszlo Szathmary *

* *

* This program is free software; you can redistribute it and/or modify it *

* under the terms of the GNU Lesser General Public License as published by *

* the Free Software Foundation; either version 2.1 of the License, or *

* (at your option) any later version. *

* *

* This program is distributed in the hope that it will be useful, but *

* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *

* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public *

* License for more details. *

* *

* You should have received a copy of the GNU Lesser General Public License *

* along with this program; if not, write to the Free Software Foundation, *

* Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *

* *

******************************************************************************

*/

import java.io.BufferedReader;

import java.io.DataInputStream;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.FileWriter;

import java.io.InputStreamReader;

/**

* dl

* dtPurpose: GraphViz Java API

* dd

*

* dtDescription:

* dd With this Java class you can simply call dot

* from your Java programs

* dtExample usage:

* dd

* pre

* GraphViz gv = new GraphViz();

* gv.addln(gv.start_graph());

* gv.addln("A - B;");

* gv.addln("A - C;");

* gv.addln(gv.end_graph());

* System.out.println(gv.getDotSource());

*

* String type = "gif";

* File out = new File("out." + type); // out.gif in this example

* gv.writeGraphToFile( gv.getGraph( gv.getDotSource(), type ), out );

* /pre

* /dd

*

* /dl

*

* @version v0.4, 2011/02/05 (February) -- Patch of Keheliya Gallaba is added. Now you

* can specify the type of the output file: gif, dot, fig, pdf, ps, svg, png, etc.

* @version v0.3, 2010/11/29 (November) -- Windows support + ability

* to read the graph from a text file

* @version v0.2, 2010/07/22 (July) -- bug fix

* @version v0.1, 2003/12/04 (December) -- first release

* @author Laszlo Szathmary (a href="jabba.laci@gmail.com"jabba.laci@gmail.com/a)

*/

public class GraphViz

{

/**

* The dir. where temporary files will be created.

*/

//private static String TEMP_DIR = "/tmp"; // Linux

private static String TEMP_DIR = "c:/temp"; // Windows

/**

* Where is your dot program located? It will be called externally.

*/

// private static String DOT = "/usr/bin/dot"; // Linux

private static String DOT = "D:\\Program Files\\Graphviz2.30\\bin\\dot.exe"; // Windows

/**

* The source of the graph written in dot language.

*/

private StringBuilder graph = new StringBuilder();

/**

* Constructor: creates a new GraphViz object that will contain

* a graph.

*/

public GraphViz() {

}

/**

* Returns the graph's source description in dot language.

* @return Source of the graph in dot language.

*/

public String getDotSource() {

return graph.toString();

}

/**

* Adds a string to the graph's source (without newline).

*/

public void add(String line) {

graph.append(line);

}

/**

* Adds a string to the graph's source (with newline).

*/

public void addln(String line) {

graph.append(line + "\n");

}

/**

* Adds a newline to the graph's source.

*/

public void addln() {

graph.append('\n');

}

/**

* Returns the graph as an image in binary format.

* @param dot_source Source of the graph to be drawn.

* @param type Type of the output image to be produced, e.g.: gif, dot, fig, pdf, ps, svg, png.

* @return A byte array containing the image of the graph.

*/

public byte[] getGraph(String dot_source, String type)

{

File dot;

byte[] img_stream = null;

try {

dot = writeDotSourceToFile(dot_source);

if (dot != null)

{

img_stream = get_img_stream(dot, type);

if (dot.delete() == false)

System.err.println("Warning: " + dot.getAbsolutePath() + " could not be deleted!");

return img_stream;

}

return null;

} catch (java.io.IOException ioe) { return null; }

}

/**

* Writes the graph's image in a file.

* @param img A byte array containing the image of the graph.

* @param file Name of the file to where we want to write.

* @return Success: 1, Failure: -1

*/

public int writeGraphToFile(byte[] img, String file)

{

File to = new File(file);

return writeGraphToFile(img, to);

}

/**

* Writes the graph's image in a file.

* @param img A byte array containing the image of the graph.

* @param to A File object to where we want to write.

* @return Success: 1, Failure: -1

*/

public int writeGraphToFile(byte[] img, File to)

{

try {

FileOutputStream fos = new FileOutputStream(to);

fos.write(img);

fos.close();

} catch (java.io.IOException ioe) { ioe.printStackTrace();return -1; }

return 1;

}

/**

* It will call the external dot program, and return the image in

* binary format.

* @param dot Source of the graph (in dot language).

* @param type Type of the output image to be produced, e.g.: gif, dot, fig, pdf, ps, svg, png.

* @return The image of the graph in .gif format.

*/

private byte[] get_img_stream(File dot, String type)

{

File img;

byte[] img_stream = null;

try {

img = File.createTempFile("graph_", "."+type, new File(GraphViz.TEMP_DIR));

Runtime rt = Runtime.getRuntime();

// patch by Mike Chenault

String[] args = {DOT, "-T"+type, dot.getAbsolutePath(), "-o", img.getAbsolutePath()};

Process p = rt.exec(args);

p.waitFor();

FileInputStream in = new FileInputStream(img.getAbsolutePath());

img_stream = new byte[in.available()];

in.read(img_stream);

// Close it if we need to

if( in != null ) in.close();

if (img.delete() == false)

System.err.println("Warning: " + img.getAbsolutePath() + " could not be deleted!");

}

catch (java.io.IOException ioe) {

System.err.println("Error: in I/O processing of tempfile in dir " + GraphViz.TEMP_DIR+"\n");

System.err.println(" or in calling external command");

ioe.printStackTrace();

}

catch (java.lang.InterruptedException ie) {

System.err.println("Error: the execution of the external program was interrupted");

ie.printStackTrace();

}

return img_stream; }

/**

* Writes the source of the graph in a file, and returns the written file

* as a File object.

* @param str Source of the graph (in dot language).

* @return The file (as a File object) that contains the source of the graph.

*/

public File writeDotSourceToFile(String str) throws java.io.IOException

{

File temp;

try {

temp = File.createTempFile("graph_", ".dot.tmp", new File(GraphViz.TEMP_DIR));

FileWriter fout = new FileWriter(temp);

fout.write(str);

fout.close();

}

catch (Exception e) {

System.err.println("Error: I/O error while writing the dot source to temp file!");

return null;

}

return temp;

}

/**

* Returns a string that is used to start a graph.

* @return A string to open a graph.

*/

public String start_graph() {

return "digraph G {" ;

}

/**

* Returns a string that is used to end a graph.

* @return A string to close a graph.

*/

public String end_graph() {

return "}";

}

/**

* Read a DOT graph from a text file.

*

* @param input Input text file containing the DOT graph

* source.

*/

public void readSource(String input)

{

StringBuilder sb = new StringBuilder();

try

{

FileInputStream fis = new FileInputStream(input);

DataInputStream dis = new DataInputStream(fis);

BufferedReader br = new BufferedReader(new InputStreamReader(dis));

String line;

while ((line = br.readLine()) != null) {

sb.append(line);

}

dis.close();

}

catch (Exception e) {

System.err.println("Error: " + e.getMessage());

}

this.graph = sb;

}

} // end of class GraphViz

通过下面这个类调用graphViz.java

import java.io.File;

public class Proba

{

public static void main(String[] args)

{

Proba p = new Proba();

p.start();

// p.start2();

}

/**

* Construct a DOT graph in memory, convert it

* to image and store the image in the file system.

*/

private void start()

{

GraphViz gv = new GraphViz();

gv.addln(gv.start_graph());

gv.addln("A - B;");

gv.addln("A - C;");

gv.addln(gv.end_graph());

System.out.println(gv.getDotSource());

String type = "gif";

// String type = "dot";

// String type = "fig"; // open with xfig

// String type = "pdf";

// String type = "ps";

// String type = "svg"; // open with inkscape

// String type = "png";

// String type = "plain";

File out = new File("/tmp/out." + type); // Linux

// File out = new File("c:/eclipse.ws/graphviz-java-api/out." + type); // Windows

gv.writeGraphToFile( gv.getGraph( gv.getDotSource(), type ), out );

}

/**

* Read the DOT source from a file,

* convert to image and store the image in the file system.

*/

private void start2()

{

// String dir = "/home/jabba/eclipse2/laszlo.sajat/graphviz-java-api"; // Linux

// String input = dir + "/sample/simple.dot";

String input = "c:/eclipse.ws/graphviz-java-api/sample/simple.dot"; // Windows

GraphViz gv = new GraphViz();

gv.readSource(input);

System.out.println(gv.getDotSource());

String type = "gif";

// String type = "dot";

// String type = "fig"; // open with xfig

// String type = "pdf";

// String type = "ps";

// String type = "svg"; // open with inkscape

// String type = "png";

// String type = "plain";

File out = new File("/tmp/simple." + type); // Linux

// File out = new File("c:/eclipse.ws/graphviz-java-api/tmp/simple." + type); // Windows

gv.writeGraphToFile( gv.getGraph( gv.getDotSource(), type ), out );

}

}

java 如何调用另一个类的窗体并显示?

要调用另一个类的窗体并显示,可以将另一个窗口的类new一个对象,然后设置可见。

1,比如两个类,一个登录界面Login,一个主界面Main

2,在Login中登录按钮添加监听事件

3,在监听事件中添加代码

{

// 登录验证。

if(ok){

Main frame = new Main();

frame.setVisible(true); // 打开新界面

dispose(); // 关闭当前界面

}

}

如何解决java调dll报Unable to load library的错误

解决java调dll报Unable to load library的错误可以尝试以下方法:

载入库文件有两个函数,System.load 和 System.loadLibrary。

当使用System.load时,需要输入文件的全路径,例如:System.load(“/tmp/test.so”);

当使用System.loadlibrary时是在系统的library 的目录中需找复合条件的库文件,可以使用-Djava.library.path=[path]参数,来指定Java程序加载库文件的路径,或者将库文件(*.so,*.dll)复制到include的默认路径,Linux一般是/usr/lib目录下,当然你可以编辑/etc/ld.so.conf.d/下的文件,设定自己的库查找路径ldconfig -v|grep xxx看看有没有你的动态库。

Linux还要注意,使用System.loadLibrary(name)方法其中参数内容与Windows有区别,Linux中的的库文件名为libname.so,Windows为name.dll。

在Windows中尽量使用Windows的C/C++编译器生成dll文件,否则会出现问题。

不过具体问题还要具体对待!

java调用dl的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java调用dll找不到指定模块、java调用dl的信息别忘了在本站进行查找喔。

The End

发布于:2022-12-01,除非注明,否则均为首码项目网原创文章,转载请注明出处。