How would I get system info using java in a java applet. I nid to use this in my gaming website to find whether the clients's system can handle the requirements of some pc games
I will really appreciate the help.
I think that the most reasonable and light-weight way to do that would be to detect the underlying OS, and parse the output of some command line commands. (for example, uname and the contents of the file /proc/meminfo on Linux)
Java graphics performance for games has been shown to come down to the drivers that the card uses, on occasions, so I doubt any of this information will be of much use to discover if the game will run OK.
It would be more useful to run a test on a fixed size rendering surface and count how many FPS can be drawn.
Related
I have made a Screen Recorder using Java Swing and Xuggler 5.4. I have developed it in Windows 8 64 bit. It's working excellent for Windows. But at client side on Linux's environment , nothing is working. I have searched thoroughly but not getting any solutions. I have checked this thread , but it didn't work for me.
Then I tried to create simple Transparent window in Linux but it's also not working. I was not able to click through the Resizeable Panel. I have used the same JRE version (1.7) for both. Have I miss understood Java's Cross Platform Support as far as Swing is concerned?
Please Give Me Some Advice...
I have always found logging to be the best debugging tool at your disposal! Many a times, java debuggers take you into APIs where you need not go every time. Logging values of your variables, and generic 'I have reached till this point' statements make life a lot easier.
So, I suppose you have ample logging done in your code. That could give you clues on what's happening on your client's system.
Are the right environment variables set? Are they pointing to the correct Java versions you need.
If there are some specific Screen capturing requirements(plugins / modules / API) your code has, are they available on the Linux m/c?
Like #MadProgrammer said, in the end, Java has to talk with the native graphics APIs to render your screen.
I would try to debug it in this way -
Check whether my main screen loads or no(by disabling the screen capture functions for a while).
if not, dig deeper.
Check whether all necessary components for capturing screen(audio and video) are available.
Check whether the code is being run with appropriate permissions to control the h/w devices you may need.
For both the built-in mic and built-in input on my MacBook Pro, the following lines both return false:
line.isControlSupported(FloatControl.Type.VOLUME);
line.isControlSupported(FloatControl.Type.MASTER_GAIN);
the line is an instance of TargetDataLine and has been successfully open()'d.
Because I can't set the gain, any audio I capture is at an extremely low level and is swamped by noise. The JVM (1.6.0_24, com.apple.javajdk16.cmd, OS X 10.6.7) also frequently crashes when calling TargetDataLine.close().
Anyone had any luck with this?
Check this - here are OS X java sound demo-apps.
http://java.sun.com/products/java-media/sound/samples/JavaSoundDemo/
Have a working os x gain control too.
Based on comments:
Check this too: http://www.jsresources.org/faq_audio.html#recording_volume , but honestly never tried it. At the page:
The obvious solution would be to get a
Control object of type VOLUME or
MASTER_GAIN for the TargetDataLine and
manipulate the volume via this object.
However, this is not possible, since
no known Java Sound implementation
supports any controls for
TargetDataLine instances.
What you can do is to use the system
mixer to control the recording volume
--- it affects hardware settings in the soundcard. One possibility is to
use the mixer application of the
operating system. The other
possibility is using Port lines from
inside a Java Sound application. See
the section Ports for details.
I'm trying to capture a video of a currently running swing application from within the application (the user presses a record button to start recording). I'm not sure how to go about creating a video that records "live." I've looked into using Xuggler, but that isn't available for 64-bit windows (on a 64-bit jvm), and that is important for this application. I don't think it would be feasible to save each screen off as images and then stitch them together because the video could run for several minutes resulting in a very large number of images.
Does anyone have any experience with this and can point me to some ideas on how to do this?
thanks,
Jeff
I was also going to suggest using Robot to take screenshots, but as you said, you would need a way of limiting what is captured. Detecting input events like keys and mouse movement could hint at when is a good time to take another screenshot, and perhaps limiting it to 2 frames per second. When stitching the images back together, the only way you could determine the timing is if you named the files using a timestamp format (with milliseconds).
I have a java application I wrote that loads up a TTF font and uses the drawString method from Graphics2D. This gets called every 50ms with the x and y positions changing each time to make the text move. When I run the program on Windows, I get 0-1% CPU usage, but on Mac I get about 75% usage. This Windows machine does have a better CPU but there's no way there should be that big of a difference. I think it has to do with Hardware Acceleration and I want to know how enable it. I found some Mac specific Java properties, but none of them lowered my CPU usage. Any ideas how to increase Java 2D performance on OS X? Thanks.
EDIT1: I thought that these properties would help but they didn't.
System.setProperty("sun.java2d.opengl", "true");
System.setProperty("apple.awt.graphics.UseQuartz","true"); System.setProperty("apple.awt.graphics.EnableQ2DX","true");
EDIT2: You can download the project source and byte code here: http://drop.io/ExampleScreenSaver
EDIT3: Since drop.io no longer exists, I uploaded the project to Google Code. Now you can browse the code without downloading it. I still have no idea how to approach this problem so any help would be appreciated.
Run the profiler in "jvisualvm" to identify where the time goes.
Apple JVM font handling is specific to MacOS X. For instance, if a glyph is not found for a character in the current font, the JVM looks for another font to display the character. Also, antialiasing is enabled by default (you should check that you have it enabled on Windows if you want to compare).
I am not surprised Apple's implementation is using more CPU.
OpenGL can be enabled when calling java e.g.
java -Dsun.java2d.opengl=true MyJavaGame
Too enable opengl from inside your java application
System.setProperty("sun.java2d.opengl", "true");
Not sure how this pans out on the iOS / Linux / Android and may require more looking into.
Hey, I've been having this problem for a while now and I was hoping someone could help.
I make small games using Java on Mac OSX 1.6.3 and if I use PNG's as the image format my CPU usage by Java skyrockets to say 50% (on a very small 2D game). However if I use GIF as the format my CPU usage by Java stays constant at 10% which is reasonable.
What is causing this problem?? It occurs on every game I develop using PNG's so I always just switch to GIF's.
The problem is now that i need to use a PNG for its variable alpha properties rather than just plain transparency. This is not available using GIF's.
The problem is present on Java SE 6 and previous versions. I am using an early 2009 Mac Book Pro 15".
The problem does not occur on a Windows PC running the same game. The CPU usage due to Java using PNG's on a Windows PC (I have tried XP, Vista and 7) is always constantly low at ~10%.
Any help would be greatly appreciated.
Thanks :)
Transparency is probably at the root of the issue, since it's a rather expensive feature. My guess is that Java2D on Mac doesn't use hardware acceleration, while on Windows it does.
Are you running the JRE that comes with MacOS?