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.
Related
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 3 years ago.
Improve this question
I'm trying to decide if JNI is for our use case.
We have a library written in C++ that fetches data from Database/RPC using multiple threads, and we want to create a wrapper to let Java code be able to call it.
I'm not familiar with JNI, so I would like to know if C++ multithreading will still work properly in this case.
Thanks.
I don't see any major issues in neither direction. Unless you have something really specific.
Here you have sample that calls JNI code from multiple threads:
http://jnicookbook.owsiak.org/recipe-No-024/
Here you have sample that calls Java from multiple C threads:
http://jnicookbook.owsiak.org/recipe-no-027/
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 7 years ago.
Improve this question
I am wondering about the efficiency of small Java applications. I would like to write a small screenshot application that sits in the taskbar tray. Since this application will be very small and always running, is it worth the overhead of having a JVM running in the background all the time? Thank you in advance for any help.
EDIT: Rephrasing question: Is this an example of something that would be better written in an application that could be run natively instead of Java which requires a JVM to run?
As said above, you have to know whether it is worth it.
If you want to minimize the memory footprint of your application have a look at the guide from Oracle:
Tuning For a Small Memory Footprint
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()
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 9 years ago.
Improve this question
I am busy doing some research and I need to do a comparison between two methods of system monitoring. I have to compare the total memory of overhead and computation required when queries are made to an external software package (i.e one that I did not create but running on the same system) as well the overhead in my software package (written in JAVA) when including all the libraries and making all the queries.
Does anyone have any suggestions on how I can approach this task to achieve these goals? Are there any general profiling solutions available that just "plug" into your system monitor and retrieve the system statistics this way? Or just a pointer in the right direction would be more than helpful right now as I am completely stuck :/
Thanks in advance.
You can use VisualVM (For sure in Windows, but don't know about Linux) (or) You can write a simple program using JMX API.
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.