How do I check a clients Java Version? - java

I want to create an Executable Jar file that when run, checks the currently installed version of Java on that computer and displays it for the user. I have searched online but in vain, I cannot find any code that allows a Jar file to check. I know that the Java website has it ( http://www.java.com/en/download/installed.jsp) I can't find a way to replicate it in Java Code. Any help would be very much appreciated.
Note: Sorry if this question is really stupid and has a really simple answer... I just spent half an hour trying to find a solution and I couldn't so I need your help! Thanks
Edit: I don't need the code for displaying it, just to get the version is enough for me thanks!

System.getProperty("java.version");

Calling System.getProperty("java.version"); will give you version of the installed JRE which is what you want. Also take a look at other System properties, you may find some of them also useful.

Related

Is it possible to embed JDK and other requirements into runnable jar?

Two days ago I got close to finishing a java program that wrote, I wanted to let some friends play with it for a bit to find flaws etc. I created a runnable jar trough Eclipse and then I used Launch4j to transform the runnable jar into a .exe
It worked perfectly fine on my pc, but any other user couldn't open it. After a while I discovered that when people would install java JDK, it worked for about 40%, but this atleast pushed me in the direction of what the flaw is. Is there a way to (automaticly?) embed everything in the jar that my program is in need of? Or is there a way to determine what exactly it all is that people need for the .exe to run and what they are missing by running some pre-checks that can re-direct them to links where they can download this? I can't seem to find much on this subject, so I probably made a mis assumption somewhere, any help/clearance is appreciated!
There is a new tool called jpackage, which should do what you want.
Also see the User's Guide.

Using ops from Tensorflow.contrb on Windows via Java API

I would like to load an op from tf.contrib, specifically "_beam_search_ops". I use Tensorflow 1.6 from Maven.
Following the answer at Issue while loading/serving tensorflow model in java using estimators , I'm able to do so on Ubuntu 17.10.
The code looks like so:
TensorFlow.loadLibrary("_beam_search_ops.so");
Then I try to do the same in Windows 10 with code
TensorFlow.loadLibrary("_beam_search_ops.dll");
And it fails with
java.lang.UnsatisfiedLinkError: D:\Users\ALEXAN~1\AppData\Local\Temp\deep_api_plugin\_beam_search_ops.dll not found
at org.tensorflow.TensorFlow.loadLibrary(TensorFlow.java:47)
So what is the reason for this?
While I was writing and researching the question, I've stumbled on the solution.
In order to resolve the problem, a _pywrap_tensorflow_internal.pyd file should be copied to the folder where _beam_search_ops.dll resides. I understand that this is also some kind of dll, but do not understand why it is necessary for Windows and not for Ubuntu. If anyone happens to know, please enlighten me.
Also I understand that this sort of additional information should be provided in a comment to the original answer, but unfortunately I do not have enough reputation to comment and thought this answer could help someone.
Edit: I was too quick to celebrate. With this answer a library is loaded without exception, but the model cannot seem to use it, failing with
Exception in thread "main" org.tensorflow.TensorFlowException: Op type not registered 'GatherTree' in binary running on DESKTOP-EB6GIDR. Make sure the Op and Kernel are registered in the binary running in this process.
at org.tensorflow.SavedModelBundle.load(Native Method)
at org.tensorflow.SavedModelBundle.load(SavedModelBundle.java:39)
Search for answer should continue.

How to use FreeTTS in IntelliJ IDEA

I need to use FreeTTS in a Java program. It's a really small application that just speaks out a certain text that was typed in by the user. I have no idea how to get this work though... I have downloaded the .zip from the FreeTTS site ( http://freetts.sourceforge.net/docs/index.php ), but how should I proceed to get it to work? As IDE I use IntelliJ IDEA. Could someone help me get to how to use it? I've never really manually added something to use in applications, I wonder, when it's added, how it can be used in a program (via import?). I hope someone can help me here, thanks in advance.
Extra info: I'm using a Mac.

Run Java ScreenGrabber example

I'm trying to test the Screen Grabber sample from JMF. Could anyone tell me how to write the main method to run this example?.
I have reviewed a lot in Google and have not found a way to make it work. because I do not know which of the two classes (LiveStream or DataSource) I must to use in the main method.
otherwise, I tried running the command:
java JMStudio screen://0,0,160,120/10
But it shows me the following exception:
UNABLE_CREATE_PLAYER*javax.media.NoPlayerException: Cannot find a Player for :screen://0,0,160,120/10
Thanks for the help.
Greetings!
Don't.
JMF never really worked out and has been abandon. (Google: "JMF is dead".) Find another mechanism for screen grabbing.
it's a late answer, but with the same hopes as Lobo, i'd like to add some constructive info :
1) JMF is old but also an old gun. it's working
2) it's pure Java, and if you are a Java guy, it will be helpful, this way or that way
3) use the methods you mentioned, if you can. follow the tutorial. otherwise, there is a free package that can be downloaded from http://www.kemottron.com, MODERATOR-CONFERENCE, you can try. pure Java, and it captures your desktop and broadcast to the Internet.
regards,

Where can I find "Device" file to add to EclipseME java project?

I installed JavaME and EclipseME, and I'm trying to make a Hello World to my Nokia5530. But the imports are not working.
This page says that I need a "Device" file, but I don't know where to find it.. any idea?
Since it appears no on else is helping with this, I will start an answer, and put in my last comment into here.
OK, you need to install the Nokia SDK and then import it, as explained here, though your phone may not be series 60, you will need to d/l and then import the appropriate nokia sdk version: http://wiki.forum.nokia.com/index.php/Installing_Java_ME_development_tools_for_S60#Configuring_EclipseME
I haven't tried the suggestions here as I primarily develop on Windows at the moment, but the idea of using wine to install the SDK, and then move the files to an appropriate place on Linux sounds like a reasonable suggestion. I don't know if the suggestion below of compiling it yourself would be useful, but, there were some suggestions in the link below that may help you solve this particular problem.
http://www.wirelessforums.org/alt-cellular-nokia/nokia-sdk-linux-8895.html

Categories