Java native methods [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I can't find the relative code to the native methods memchr, memcmp, memcpy, memmove, memset in Java. Could someone explain what do these methods stand for? What do they really do?
I want to acceed to the value pointed to by a variable in my program and I'm wondering if these methods could help me.
Thank you in advance.

Java native methods are not encouraged to use unless you can not get the things done using available java methods. Also implementations of native methods can be differ from java versions. If you really want to see them you just download the jdk with source code from openJDK and have a look at them. On the other hand you can have your own implementations for these native methods as well. Have a look at here
to get more details on how to override these native methods

There aren't any. Therefore your question about what they do doesn't make sense. The closest approach in Java is System.arraycopy().

Related

What is the most efficient(fastest) way of passing data from C++ to Java? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
What is the most efficient way of passing data from C++ to Java?
The Java application will need to call the C++ application to retrieve the data.
I can see the following ways of achieving this:
Using JNI
Using a file based approach
Using SWIG
My current thinking is to use JNI. AM I missing a better method before I commit?
Java Native Interface allows you to pass anything back and forth between C++ and Java. It supports both directions, but can be tricky. There are others you can look at Swig is one and then you have JNA. I would go with JNI
JNI would be the best approach. Notice that javah creates compatible header-files for your java-class, its very tricky to to write compatible header-files by your own, so please use javah.

Find least used icons/files/folders on desktop in windows [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have an assignment to find least used icons on desktop in Windows.
I need to code using JAVA. Which property of the File object in JAVA will be useful?
I have started analysis on it. A help will be much appreciated.
Have you checked out the File API? File#lastAccessTime is probably what you are looking for. Keep in mind that this only works in Java 7.
As for FREQUENCY of use, I do not think Windows keeps any data per-file... So you will have to rely on the last time of modification, possibly vs time of creation. The Java function you will need to rely on is lastModified(), eg
file_list[i].lastModified()

How to dynamically generate code for object oriented tool? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am kind of stuck in a dilemma. I want to create a tool that would generate code on the fly by taking various parameters from the user. The codes have a few similar features and few things need to be altered from one code to other to other. Based on the parameters, I can have 15 different codes. Till now I have been using file handling in Java to implement this as I have the created codes in different files but this doesn't seem to be a great method. Can you please suggest something that is better than this??
Since Java 1.6 you can compile in memory whatever you want. Take a look at this code:
http://code.google.com/p/cachos/source/browse/trunk/cachos/src/com/peyrona/cachos/InMemoryCompiler.java
http://code.google.com/p/cachos/source/browse/trunk/cachos/src/com/peyrona/cachos/InMemoryExecutor.java
In this example you can see how you can compile a source code stored in a String in memory, without using the disk.
Source (Spanish): http://www.javahispano.org/portada/2011/12/12/compilar-y-ejecutar-codigo-java-en-memoria.html
I think this is what you're looking for.

How can C/C++ source code and libraries be used in Java? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Is there any way that a .c and .h files can be used in eclipse? On a 32 bit xp,using jre1.6. I do not know any C. The code is about 500 lines
Not directly. You would need to know some c to add interface methods to be able to use JNI.
JNI is the key to use c or c++ code.
You can either invoke it using JNA or JNI, JNA generally being the easier one to use.
You'll need to alter your code though by reading up on the two technologies - it's not a magic bullet.
Your best bet is to rewrite the code.
Any kind of automated conversion usually produces unmaintainable code. If you opt for this solution, just pick one of these :
http://tech.novosoft-us.com/product_c2j.jsp
http://www.soften.ktu.lt/~stonis/c2java/

program in java to get info about Ram [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want a program to get information about RAM
How can i do that?
There's a couple of memory-related methods in the Runtime class, but note that they only give information about the amount of memory available to (or used by) the JVM, not the hardware it runs on.
Generally, Java is the wrong language to do this kind of thing, since it requires access to OS APIs that Java does not provide.
Most of the information you need will be contained in the Runtime class. Have a look at the link. It should be straightforward. If you run into problems with it, I will try to help you out further.

Categories