I'm trying to build an app that takes a screenshot of specific program that's open(an external program, one that I did not code), but my research just keeps pointing me to c++. I was curious if there's a way to do this, or access Windows stuff in general from Java, or if I just need to jump to a scripting language or C. Thank you.
it depends, here is what I found so far.
you can access process names listed on the Task Manager via the Runtime object found here
an explanation on how to use it is on stackoverflow already here.
but you need to know the name of the app you want to find, such as mspaint.exe, msword.exe, myprogram.exe, and so on...
now if you know the executable name, and the application happens to be running, you can use Java's Robot library to get a 'screenshot'. the java API library for Robot is found here and an example of how to use it can be found here. The stackoverflow answer goes into details about using Robot vs another custom tailored approach to just getting a screenshot.
Also note that the pages i linked to are for Java 7, there is also a Java 8 library found here which would be the more current version.
I usually just google "java api X" and whatever I'm looking for.
hope that helps.
Related
I am trying to use Vowpal Wabbit through Java. I have downloaded and successfully compiled the code from GitHub. The command line tool works fine.
After having a quick look at the repository (especially here), I can only assume that using it through Java is supposed to be already possible, and I don't really want to reinvent the wheel.
A wrapper around Vowpal Wabbit that allows use through Java. This wrapper is designed to be self contained. Because
of the use of JNI, a number of platforms are supported in this JAR.
I have added the maven dependency (found here) to my project, but without any kind of document, I don't really know where to start.
I have seen in another question that it seems to be possible to use VW with Java, but the guy only uses Runtime.getRuntime.exec() to call his bash command, and I can't find any documentation about any other way of doing (and there are only 2 questions mixing VW and Java on SO, which doesn't help).
I am new to JNI, so most likely there is something easy that I don't see.
To be perfectly clear, my questions are :
Should I just make a valid vw command and use it through Runtime.getRuntime.exec()? This doesn't seem to be the spirit of JNI, for there is no need for any wrapper/library for this. Plus, this doesn't make it very portable.
Where (the hell) is the (Java API) documentation ?
Any kind of help or guidance would be welcome.
I was one of the two primary authors of the VW JNI wrapper. Since the posting of this question the interface has significantly changed. We now encourage users to compile the native side on their own and provide it on the java.library.path. We have updated the README significantly to show how to use the library from Java.
I totally agree with your criticism that we have not published the Java API. I will work on that the next time I modify this code. In the meantime please feel free to clone the library and run mvn install and you can generate the Java API docs yourself. They should be quite detailed as we spent a lot of effort writing detailed docs.
You may checkout vowpal wabbit JNI wrapper we've built in Indeed: https://github.com/indeedeng/vowpal-wabbit-java.
We wrote integration test that can work as usage examples and we wrote API documentation as well. Check "using the library" section of README.
Hope this will help.
I don't think this adds a lot, but none of the previous answers really provided a clear answer. Like #Macchiatow mentioned, to use the Java wrapper which comes with Vowpal Wabbit, you would:
(on the project root dir) make all java or make java
cd into java and verify the installation with mvn test
you'd then mvn install to have the Java API jarred up and placed in your local maven repository. Supposedly this builds the JNI parts on your machine, so as to fit the C/C++ libraries of your platform if you have the necessary native C/C++ libraries installed and available to the make command.
you'd supposedly be able to include the vowpal package/s from those jars in the build tool used in your own project (ant/maven/boot/leiningen/sbt/etc. as in here).
For more background maybe see the Vowpal Wabbit Java readme. I think what it tries to say there, is that if you want a ready made jar from maven central, you should make sure it's the same vowpal version you're using, but without knowing more I'd guess if you built it like above, you are by definition using the same version.
I've had the above process work off a fresh clone, with Ubuntu 16.04 and Java 8.
This link may be of some help with regards to setting up a JNI wrapper.
I wasn't able to find Java API documentation anywhere, but Java code seems well documented - did you maybe try generating Javadoc yourself from the code?
There is indeed Java JNI wrapper to have a basic access to VW. By basic I mean to teach your model and to predict probability later on. They also provide Python library that can do far more than wrapper for Java. Recently I was forced to expose few more VW methods to Java by extending code provided.
Back to the questions:
Rather use the vw-jni artifact available in central maven repo and clone their code and run make all java. I some cases compiling code yourself will be the only solution, as for example provided artifact won't run on OpenSuse (my case)
Code available pretty straight forward. VWLearners::create is a factory to get an instance of VW from Java.
I've learnt python recently and I want to make an app for android. But everywhere on the net, it seems Java and Eclipse are the only ones that can be used.
So, my question is:
1) Can I use python to make an android app?
2) What kind of platform should I use to make an app with python?
Thanks guys!
If you're just looking to run Python scripts, try QPython.
If you're looking to make your Python code run like a native app, or just something more robust than the above, try SL4A.
If you're looking to effectively use Python as a library, and compile an .apk with the Python library included, try Kivy: github.com/kivy/python-for-android.
That said, you'd likely get a lot of benefit from learning Java, and not just for programming natively in Android (which would give you access to a much wider feature set and make your app run more efficiently).
Check out the Scripting Layer For Android, aka SL4A.
Here is a blog for getting started. The blog promises more entries in the series but there don't seem to be any. Still, it is a great starting point. There's quite a few parts to pull together so be patient and check the bottom of that blog entry for dozens of useful links.
If you want to contain everything to the Android device, including the IDE (pretty slick), check this out.
Here's a book from APress that could help with more advanced concepts: Pro Android Python with SL4A
I want to develop a small Java program using some input like the pen of a Wacom graphictablet and found only the very active JPen project but are there some more possible alternatives without JNI or JNA (without any additional needed dll files), a pure Java implementation?
You can take a look at JTablet. From another SO thread.
It seems JPen moved to GitHub and this might be the best solution at the moment.
The other alternative solutions are not developed and maintained anymore.
https://github.com/nicarran/jpen
I want to create a web based java tutorials kind of project which involves jquery, css, jsp, springs etc .,
so I actually want to practice these technologies resulting a good product. The content of this tutorial can be edited by any user and rated by clients according to the chapter etc.,
I have few such ideas.
One primary idea being have a web based compiler and executor . Similar to w3schools. I know its difficult for a compiler of server side technology on a browser.
My questions are:
Are there any such open source java
compiler/executor services available
which can be used?
Is anyone interested to work on such
project (in case there isnt any)?
EDIT:
I am planning to use Compiler in java and Beanshell. Any better solutions ?
Google App Engine is the one, which one can you help to set up Free online Java Compiler, But for that you need to have an account to proceed.
Few other places you can defnitely Check
http://compilr.com/
If you have Applets,
http://www.innovation.ch/java/java_compile.html
EDIT : As Stephen Suggests, Download JRE and JDE and use it from oracle website
http://www.oracle.com/technetwork/java/javase/downloads/index.html
With http://www.browxy.com you can compile and run java console application and applets
You would need a script on your server that accepts the sourcecode, compiles it and runs it, however I'm pretty sure, you don't want to run arbitrary code.
If you still want to do it, take a look at Google's AppEngine, they do allow users to upload their (compiled) java programs and don't seem to have had any problems with it.
This question is interesting. In fact, Tomcat JSP server is an online compiler for Java Servlet. May help you a little in your case. (Not for traditional Java, though).
Imagine that you gave user an input form for Java codes ( preferably a WYSIWYG editor ), the codes will be written in a temp JSP file, and then your code compile and run the JSP.
But be careful , JSP is too powerful ( as it can touch file system, etc. ). Make sure your security measure is set.
I've used ideone.com before when discussing Java code with someone in a remote location. It is a web based IDE that handles Java as well as a lot of other languages, and is very useful.
If you are trying to do it yourself, you should be aware java6 and above have compilation built into the language in the javax.tools package.
You may want to check out Fixoncloud compiler. It's a web-based collaborative online compiler. Anyone can make changes to the code and you can also track history of your code. The compiler supports C, C++ and Java.
Depending on the permissions set to the code, the owner can also make his code completely private and permit only specific users to view/modify the code.
Here's the link to the compiler:
http://www.fixoncloud.com/Home/compiler/index.php?id=254
As the title suggests, we have a Java (Swing) desktop application, and we'd like to be able to have some basic access to the Jump Lists (in the new Windows 7 taskbar).
In particular, we'd like to be able to add some "user tasks" to the jump list--the ability to start other modules in our application, maybe to close all running modules, etc.
I know that we could do this using JNI or JNA and the C API described here, but that is our option of last resort. I'm hoping that there might be an easier way--something that Sun has already implemented, or maybe a third party library or something.
Google is no help so far. Anyone else have any ideas?
There is a Java library providing the new Windows 7 features for Java. It's called J7Goodies by Strix Code. You can create your own jump lists with it. Of course it supports "users tasks" too.
This would break compatibility with other systems so Sun almost certainly won't do it.
There are a handful of desktop/toolbar integration libraries out there that make the jni calls for you, you might look for one of those that has been updated for windows 7, but if you are going to go single-platform, why not use C#? (Not that I'm a fan, I'm 100% Java, but if you're already breaking compatibility you might consider going all the way just for ease of programming)