Acessing Windows performance Monitor from java code - java

I have a java program which need to create, update and read counters in the Windows performance Monitor.
I have searched stackoverflow for previous posts about this issue and found two main articles proposed:
First is this one. It relies on unbearable Win32 API and doesn't give a complete step by step tutorial. Also, I do not know this Win32 API and do not wish to study it now.
The second is this one. It seemed to me like a better option, but it relies on nsclient component which I couldn't find anywhere on the web. However, there is nsclient++, but I am not sure it supports java (I posted there a question about it) and anyways, the tutorial is not based on it.
Maybe some has a better solution?
Many thanks, Tal.

Related

How to read/send USB data in just plain Java?

Before answering, please read all of this so you don't miss any details.
I have been looking on the internet for days, and trying to look through the javadocs, but I cannot find the answer anywhere.
How can I get connected devices through USB by using the java API. I do not want to use any libraries as they aren't reliable enough for the purpose I am using it for.
How do USB java libraries do it, what Java API does it use to connect to USB devices?
I know it may be complicated to actually work with it, but it will still be very useful.
I did seen the use of File.getRoots(), but it just gives storage, like C:/, H:/, etc. I want to be able to communicate with any USB device, like mouses, keyboards, custom hardware, etc.
Also include examples of code as well. It helps a lot in understanding it better. Make sure to also get to the point, it helps by saving time.
Update: I still have no clue on how to start.
Update 2: I found something with javax.usb, is it part of the java api, when I do say java api, I mean stuff that is already with java and where you don't need to download anything but the JRE. I am not sure as if it was, I would think someone would of mentioned something about it here. Going to try to find more into it. I can't find anything on the official java-14 docs, so guessing not.
Update 3: Haven't found an answer yet. Everything is redirecting to usb4java, which has not been updated in a couple years, 3 years in fact. Which is actually one of the main reasons I don't want to use any external library as it might get abandoned and will cause some issues with my code in the future. Hopefully someone can help soon, I desperately need an answer and the internet is no help and everything seems to redirect to libraries, which again, I don't want.
Update 4: Still on the hunt for an answer, still haven't found anything useful.
Update 5: I am seeing that I have tons of uses to do this, but don't know how to do it from scratch.
Update 6: Still on the hunt for an answer. I have been looking hard but found nothing. Looking through the USB4JAVA library code has been proven to not help much. But, I am going to keep looking, hopefully I find something soon. Found something though, it's libusb, a C program that USB4JAVA uses. Even though I won't use Java libraries, I might just use C libraries for Java, if that makes sense.

Run Apache Sling's samples

I want to run simple-demo from samples but I don't have success. What is its URL and how to reach its content?
The internationalization of usermanager-ui also doesn't work, although I installed the org.apache.sling.i18n bundle. If someone can give me a guidance I will be very happy.
In general why everything is so poor explained? The motto of Sling is "Bringing Back the Fun!", but in the last few days I didn't have so much fun! It's really painful to try to test or make something. Is there any good tutorial or book about this framework?
P.S. If I run all samples without any problems, I would create a detailed tutorial.
My personal opinion is that simple-demo is not a very current sample, I'd rather recommend hat you look at the slingbucks or espblog samples, as mentioned at http://sling.apache.org/documentation/getting-started/discover-sling-in-15-minutes.html
We might need to cleanup the Sling samples at some point, and concentrate on a few representative ones - I've put that on my way-too-long-list-of-things-to-do.
Just go through the readme.txt of the respective samples.

In Java, is there something like "DoEvents" from VB6

I'm coming from VB6 and I'm new to Java. In VB6, DoEvents gives up the processor and allows it to process other threads. Is there a similar thing in Java? How do I use it?
gives up the processor and allows it to process other threads.
Thread#yield() is the java counterpart to relinquish the control of the processors voluntarily.
From the javadoc for java.lang.Thread#yield():
A hint to the scheduler that the current thread is willing to yield its current use of a processor. The scheduler is free to ignore this hint.
Yield is a heuristic attempt to improve relative progression between threads that would otherwise over-utilise a CPU. Its use should be combined with detailed profiling and benchmarking to ensure that it actually has the desired effect.
It is rarely appropriate to use this method. It may be useful for debugging or testing purposes, where it may help to reproduce bugs due to race conditions. It may also be useful when designing concurrency control constructs such as the ones in the java.util.concurrent.locks package.
Note:
In case of Java based desktop UI frameworks like Swing, RIM's UI application, there are ways to modify the UI using invokeLater() type of semantics.
Having moved from VB6 to Java myself and having searched for an answer to this very same question at the time, I can tell you that I had to change my way of thinking about how to do things. The need for "doEvents" is most likely due to you attempting to write a Java program in the same way you wrote VB6 or an attempt to port a VB6 project "line by line" to Java. Neither is a good idea. Take a good look at the swing tutorial (if this is about UI) and the threading tutorial whether it is UI or not. Pay a close attention to and try to understand how the Event Dispatch thread works. I found the Java tutorials to be a great starting place, they are now located at Oracle: http://docs.oracle.com/javase/tutorial/ look at the samples and read the code, they are a good place to learn/experiment
You need to start thinking in Java and not translate VB6 to Java, it took me a while to get there but not too long and overcoming the need for "doEvents" will take you a long way down that path if you understand the way around it. Good luck, and welcome to Stackoverflow, this is a great place to look for help!

Cannot locate Quartz Window Services

I need to find the coordinates of windows open even when they are not launched by my application, and after some searching I came across quartz window services. However, the reference document I linked to does not mention where this is located, and it was the only document I could find about it. I have looked through other frameworks reference documents, but none of them so much as mention it.
The problem obviously arrises solely out of my own ignorance, and I did not really want to ask. But, I have searched all over the internet, and have been able to find absolutely no reference to the location of quartz windows service.
Where is it? Is it part of a framework, and if so what class is it in? All I know is what functions it contains, and that they look like exactly what I need!
Thank you in advance for any help. Also, if you know how I could figure this out for myself in the future, I would appreciate that as well.
Note: I don't know if it matters, but I am planning to use JNA to call it from Java as opposed to using it from C.
Yeah, that's a little less than obvious. By searching for "Quartz Window Services" I was able to find the link to the overview, such as it is: https://developer.apple.com/library/mac/#documentation/Carbon/Reference/CGWindow_Reference/Reference/Introduction.html
That shows that it's in the ApplicationServices framework.
Well first off, I'm not 100% certain how you're going to access C methods from Java (I've never done it myself), but if it's possible to do the bridging, you can use the Accessibility API in order to get the windows for all of the running applications (see the answer to this related question). Once you have that list of windows, you can get the frame (coordinates) of where each of those windows lives on-screen.
Another thing about using the Accessibility API, the user has to "OPT IN" to allowing it. It's not normally turned on by default.
Here's another question that closely matches yours, but the accepted answer only provides a solution to retrieve the windows for your own (currently running) application.

Java API interface

Ever since I started playing around with Scala, I have had one big question concerning the Java API: why does Oracle keep the same old HTML page with "frameset" tags and no search function at all? It looks like they haven't made it to the Web 2.0...
The Scala API documentation on the other hand, while not the best website in the web history, is several orders of magnitude more usable.
Anyways, if anybody knows why that is and, more importantly, if there exists a Java API documentation with a better interface, please let me know!
Recently, for Java 7, JavaDoc was improved so it could use custom CSS. Here are the first results: http://download.java.net/jdk7/docs/api/. The work continues and I think we'll see more when new updates come out. I do agree that ScalaDoc is superior, but they didn't have to deal with 15 years of legacy.
Javadocs provides the output in that format and its published at that address, I guess no one really saw the need for improvement, but now that you mention it, it makes for an interesting side-project. I googled around to find if there was any "better" interface but no luck.
You could run javadoc -h to see what extra options are available if you want to re-generate the javadocs. Some interesting ones are to provide custom header/footer and linking to the source, but nothing to the effect that you are asking.
Those HTML pages were made using the Javadoc tools, a standard way to build documentation in Java.
I don't know if there are other webpages with a better formatting of the API, but if it helps you with anything, and you are using an IDE and the SDK, you can see the source code for most of the files there.
JavaDoc was designed to be the lowest common denominator. Virtually any web browser can display it, even without JavaScript support.
If you are looking for quicker access and search capabilities, you can access JavaDoc from within an IDE such as Eclipse.

Categories