|
Hello,
I am very new to java.
I want to call a C-dll function from my java code and I don't know how. Can you please help?
Thanks.
Where there is a WISH, there is a WILL.
|
|
|
|
|
There are facilities for this kind of thing in the MS version of the java engine. It's documented on the microsoft java site. Basically microsoft have put in some naughty java extensions for this purpose.
You do things like
<br />
<br />
static native int MessageBox(int hwndOwner, String text, String title, int style);<br />
(This must be in a class definition, of course).
I rather doubt there are any facilities to do this kind of thing in the Sun java engine. It's too machine dependant.
|
|
|
|
|
Malcolm McMahon wrote:
I rather doubt there are any facilities to do this kind of thing in the Sun java engine. It's too machine dependant.
Yes, there is. It's called Java Native Interface.
|
|
|
|
|
That doesn't look like it would allow you to access an existing DLL though. Only one specially written for this purpose. Of course you could write an interface from there to a standard DLL.
|
|
|
|
|
That's right.
I found JNI but it sounds like it is very slow.
And you can't use existing dll.
1.You write the native methods declaration in a java class
2.Then you compile the java class (javac)
3.Generate a header file from this class using javah -jni ...
4.include this header in you dll project and provide and implementation for the generated header functions.
5.Rebuild your dll
From this point, you can use the dll via the java class methods we wrote at step 1.
I tried using JNI. It works because I could change the source of the dll and I wanted to use. But it is surprisingly slow. Now I am looking forward to using sockets.
Thank you.
Where there is a WISH, there is a WILL.
|
|
|
|
|
I'm currently developing an app that invokes a JVM from C++. The app then calls a bunch of java methods. Unfortunately, somewhere down the line, an exception has occurred in java. I'm using the env->ExceptionDescribe() function, but it only outputs to stderr (of this i'm not sure). Unfortnately, I'm running the C++ directly from Matlab (Via a mex function interface), so there is no console window in which to view exception message. Is there anyway to intercept/view the exception message that JNI so thoughtfully prints out to stderr?
|
|
|
|
|
I'm looking for a Java compiler. To improve performance of a Java based application I would like to compile the code in machine binary code - not in bytecode. I've been looking around for that compiler on the Web but couldn't find any clue.
There used to be a Java compiler called SuperCede and another with Visual Cafe but they don't seem to be maintained anymore.
So is there still a serious Java compiler somewhere ? ...and does it really improve the speed of a Java application ?
I know that this is not in the good way to deal with Java which is natively a multi-platform based language, but Windows is the only platform for my clients )
Yarp
|
|
|
|
|
There's GCJ, but it's not (yet) ported to Windows.
|
|
|
|
|
The GNU products are always good quality ones. It's obviously a challenge to compile the entire Java class libraries. I'll closely follow GCJ.
Thanks
Yarp
|
|
|
|
|
Can it be done? Help would be very appreciated.
|
|
|
|
|
does anyone know of a script that will interact with a certain program, recording certain tasks completed, like a gaming ladder.
"To wonder is to begin to understand"
|
|
|
|
|
i know a web page with a field entry and a number button pad with 9 numbers on it. 3 numbers pressed in the rite order will result in the code being cracked... ive tried viewing the source code, and its got some explanation of the code in java, but i dont get it, any help will be greatly appreciated.
|
|
|
|
|
Post a link to the site.
Jon Sagara
"After all is said and done, usually more is said than done." -- Unknown
|
|
|
|
|
InterKoro-- I cant do that, but intstead i'll post the java:
<title>name of site
function typeo(x) {
if (x.i == null) {
x.i = -1;
x.chri = 0;
x.txt = x.innerHTML;
x.lng = x.txt.length;
x.innerHTML = "";
x.style.visibility = "visible";
x.msg = "";
}
/* still making msg */
if (x.i < x.lng) {
for (x.i = 0; x.i < x.lng; x.i++) {
chr = x.txt.charAt(x.i)
if (chr == "<") {
aTag = "<";
while (chr != ">") {
x.i++;
chr = x.txt.charAt(x.i);
aTag = aTag + chr;
}
aTag = aTag;
x.msg = x.msg + aTag;
}
if (chr != ">") {
x.msg = x.msg + "<span style='display: none' id=" + x.id + "_" + x.chri + ">" + chr + "</span>";
x.chri++;
}
}
}
/* made msg */
if (x.i == x.lng) {
if (x.cmpl == null) {
x.innerHTML = x.msg;
x.cmpl = x.chri;
x.chri = 0;
}
//the number in abl variable controls time between letters
if (x.chri < x.cmpl) {
t = eval(x.id + "_" + x.chri);
t.style.display = "";
x.chri++;
ab1 = window.setTimeout("typeo(" + x.id + ")", 75);
}
}
}
function animatedObject(elementName,loop,speed,steps,endRoutines,route){
this.elementName = elementName;
this.loop = loop;
this.speed = speed;
this.steps = steps;
this.frameIndex = 0;
this.endRoutines = endRoutines;
this.route = route.split(',');
this.animate = animateObject;
this.move = moveObject;
this.show = showObject;
this.hide = hideObject;
animatedObjects[elementName] = this;
}
function stopTimeline(timelineNumber){
animationTime[timelineNumber] = animationTimeline[timelineNumber].length;
}
function startTimeline(timelineNumber) {
animationTime[timelineNumber] = 0;
timelineController(timelineNumber);
}
function timelineController(timelineNumber) {
if (animationTime[timelineNumber] <= animationTimeline[timelineNumber].length - 1) {
animationTime[timelineNumber]++;
if (animationTimeline[timelineNumber][animationTime[timelineNumber]] != null){
eval(animationTimeline[timelineNumber][animationTime[timelineNumber]]);
}
setTimeout('timelineController(' + timelineNumber + ')', 100);
}
}
function showObject(){
eval(layerObj + '["' + this.elementName + '"]' + styleObj + '.visibility = "visible"');
}
function hideObject(){
eval(layerObj + '["' + this.elementName + '"]' + styleObj + '.visibility = "hidden"');
}
function moveObject(left, top){
eval(layerObj + '["' + this.elementName + '"]' + styleObj + '.top = top');
eval(layerObj + '["' + this.elementName + '"]' + styleObj + '.left = left');
}
function animateObject(){
if (this.route.length > 4 && this.frameIndex < this.route.length) {
this.move(this.route[this.frameIndex], this.route[this.frameIndex + 1]);
this.frameIndex += 2;
setTimeout('animatedObjects["' + this.elementName + '"].animate()', this.speed);
}
else if (this.route.length == 4 && this.frameIndex <= this.steps) {
this.move(parseInt(this.route[0]) + (this.frameIndex * ((parseInt(this.route[2]) - parseInt(this.route[0])) / this.steps)), parseInt(this.route[1]) + (this.frameIndex * ((parseInt(this.route[3]) - parseInt(this.route[1])) / this.steps)));
this.frameIndex++;
setTimeout('animatedObjects["' + this.elementName + '"].animate()', this.speed);
}
else {
eval(this.endRoutines + "");
this.frameIndex = 0;
if (this.loop == "yes"){
this.animate();
}
}
}
function initAnimation() {
layerObj = (isNS) ? 'document' : 'document.all';
styleObj = (isNS) ? '' : '.style';
animationTime = new Array();
animationTimeline = new Array();
animatedObjects = new Object();
alvin = new animatedObject('alvinL','yes',100,400,'null','200,0,200,320');
bubble = new animatedObject('bubbleL', 'yes', 300, 25, 'null', '100,500,100,50');
morebubbles = new animatedObject('morebubblesL', 'yes', 300, 25, 'null', '500,500,500,50');
animationTimeline[0] = new Array();
animationTimeline[0][10] = 'alvin.show(); bubble.show(); alvin.animate(); bubble.animate();';
animationTimeline[0][50] = 'morebubbles.show(); morebubbles.animate();';
startTimeline(0);
}
var layerObj, styleObj, totalTime, currTime;
var animationTime, animationTimeline, animatedObjects;
var bon, boff;
var isNS = (document.layers);
var isDHTML = (document.layers || document.all);
can you crack the code?
)
// This is to validate the code. If
// the code is 1234 the mul = 1*2*3*4 = 24
// If your code is 9562 it will be
// usermulcode = 540 (9*5*6*2)
{
window.open("switch.pl/"+code+".shtml",'_top')
fails++
code=0 // Reset values
mul=1
digit=0
}
else
{
fails++ // Increase fails
code=0 // Reset values
mul=1
digit=0
if (fails<6)
{
if (fails<5)
{document.codepad.thecode.value="Try again"}
if (fails==5)
{document.codepad.thecode.value="Last time"}
}
else // To many tries = worp back
{
location="http://name of site/crash.shtml"
document.codepad.thecode.value="Bye!"
}
}
}
}
function keycodepad(mulcode)
{
usermulcode=mulcode
document.write("<form name=\"codepad\">");
document.write("<input type=\"button\" value=\" 1 \" onClick=\"Enter_code(1)\">");
document.write("<input type=\"button\" value=\" 2 \" onClick=\"Enter_code(2)\">");
document.write("<input type=\"button\" value=\" 3 \" onClick=\"Enter_code(3)\"><br>");
document.write("<input type=\"button\" value=\" 4 \" onClick=\"Enter_code(4)\">");
document.write("<input type=\"button\" value=\" 5 \" onClick=\"Enter_code(5)\">");
document.write("<input type=\"button\" value=\" 6 \" onClick=\"Enter_code(6)\"><br>");
document.write("<input type=\"button\" value=\" 7 \" onClick=\"Enter_code(7)\">");
document.write("<input type=\"button\" value=\" 8 \" onClick=\"Enter_code(8)\">");
document.write("<input type=\"button\" value=\" 9 \" onClick=\"Enter_code(9)\"><br>");
document.write("<input type=\"text\" name=\"thecode\" size=10 value=\"\"><br>");
document.write("</form>");
}
// Key-code script by Bart Jellema -->
keycodepad(24)
<bgsound src="music.mid" autostart="true" loop="infinite">
++interkoro++
|
|
|
|
|
this is NOT Java
Its JavaScript light typed language not Java!
"Imagination is more important than knowledge, for knowledge is limited while imagination embraces the entire world."
-Albert Einstein
|
|
|
|
|
I have an applet on my web page and I want it to display like this picture while it is loading -> http://compcom.hypermart.net/loading.gif
Anyone please tell me how can I do that?
Thank you
|
|
|
|
|
Go to www.java.sun.com
Look for javaplugin or /*something*/ you have to link to their plugin!
here is the link!
http://java.sun.com/getjava/intranet.html
"Imagination is more important than knowledge, for knowledge is limited while imagination embraces the entire world."
-Albert Einstein
|
|
|
|
|
Hi.
I'm creating a SMS-mobile sollution and the gateway that we use require us
to write files to an Outqueue for SMS-messages to be sent. The files are
simple text-files. The problem I'm dealing with is that the gateway require
our application to "lock" the file while writing to it, that is, no other
application can have file-permissions on our file. When the file containing
the SMS-message is written, the file-permissions need to change to "full
control" to allow other applications (the Gateway) to access it and delete
it once the message is sent.
Does anyone know how to solve this, or have a link to any useful information
?
Any help would be greatly appreciated !
Best Regards
Eirik Kjølsrud
Apropos Internet, Norway
|
|
|
|
|
Don't you hate it when you work hard on your project, only to find your client isn't so impressed just because of what it looks like on the outside?
If you need help with graphics and user interface layout, Z Web Graphics can help. We specialize in working with developer's to give your project the image it deserves. We know how hard you work behind the scenes, and we will help you reflect that on the surface.
All you have to do is email us at info@zwebgraphics.com, or fill out our customer profile form located on our website at www.zwebgraphics.com. It all can be done via email, by you telling us a little bit about you and your project, then we can begin designing mock up layouts, and sending you graphics via email. It is all very easy, and very inexpensive.
Contact us at info@zwebgraphics.com or visit our website at www.zwebgraphics.com for more information.
Z Web Graphics
a programmer's best friend
|
|
|
|
|
Oh! is this the place to advertise? I didn't realise,
I have a 2nd hand push bike for sale. Got two wheels and handlebars. Wear thick rubber pants and its quite comfortable. £400.95
We do it for the joy of seeing the users struggle.
|
|
|
|
|
Rassman wrote:
Oh! is this the place to advertise? I didn't realise,
I have a 2nd hand push bike for sale. Got two wheels and handlebars. Wear thick rubber pants and its quite comfortable. £400.95
Funny man...
Maybe Chris should add a free adds section...
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I'm an absolute Java beginner so please forgive me
I've got an applet (written in VisualCafe V4.5) that works fine in an applet viewer, but when I try to view it in a web page (IE6 and NS6.1) all I get is a gray box where the applet should be.
I assume the applet is correct as it's stage two of the tutorial that comes with VisualCafe Expert Edition. I'm also sure the class path name is correct.
The WebGain newsgroups hardly have any posting going on at all, and I know this may be a long shot, but I thought I'd ask this here. Thanks ever so much to anyone that can help.
Jeremy Davis
http://www.astad.org
|
|
|
|
|
The only reason I know for that to happen is that one of the classes used by the applet cannot be found. It might work in applet viewer because it is on the same machine and you set the correct classpath. But the browser is trying to "download" the classes as if they reside on a "remote" machine.
Check the "code=" and "codebase=" values in your html page that hosts the applet. "code=" must be the path of your applet class relative to the "codebase=", and all the other classes (except those came with the java language) used by your applet have to be found under "codebase=".
Hope this helps.
|
|
|
|
|
|
If don't seem to have a CODEBASE parameter. All I've got is...
<APPLET ARCHIVE="customer.jar" CODE="CustomerInfo.class" WIDTH="360" HEIGHT="233" ALIGN="BOTTOM">
</APPLET>
Exactly what is specified in the example as supplied with VisualCafe. All that is in the deployed directory the the HTML web page with <applet> in, and customer.jar
Jeremy Davis
http://www.astad.org
|
|
|
|