Install Java Web Start from an Application - java

I have a simple Java program that uses:
Runtime.getRuntime().exec("/usr/bin/javaws", [path for JNLP file])
to open a JNLP file using java web start.
However, I need to deal with the scenario of javaws not being installed. So I need to check to see if it is installed and, if it's not, install it. Any idea how to do either of those (or both)?

Firstly, you're assuming that the path to javaws is /usr/bin/javaws, which may not be the case.
If it were that simple, then you can check if the file exists:
File javawsFile = new File("/usr/bin/javaws");
if (! javawsFile.exists()) {
System.out.println("javaws not installed");
}
Having said that, java does not have to be installed to any particular location. Thus you can't assume it's in /usr/bin/. Many people will download the java binary zip and simply decompress it to their choice of location, and set the environment variable JAVA_HOME.
Now, you could go down the path of resolving the JAVA_HOME variable - but even then it'll only tell you if javaws is installed - or not.
If javaws is not installed, there is not really a way to install it - other than prompting the user to go off to the java website and download it.
The path you give is in *nix style. In this case it would require root access to install new applications - which isn't something you can simply manufacture.
Even if your user was already running your application as root, I would still be wary of this. It's not your responsibility to install software on your users' machines.

Related

Check if the given String points to a Python installation in Java

Is there any way I can check in Java if the String I'm receiving points to a valid Python installation directory?
The idea is to force the user to only give a valid path to his Python installation folder, and if the path is not valid, return an error to let them know.
This solution has a couple of problems. On *nix machines, there is not really such a thing as a installation directory.
So, instead of a directory, you might want the use to select an executable.
This will also allow you to run a python --version to check if the version is ok.

Java SE Development kit didn't installed right?

First off, let me say I did all of this while watching this video: https://www.youtube.com/watch?v=Hl-zzrqQoSE
So, I tried downloads jdk-8u60 for windows 64bit, as seen right here: http://www.oracle.com/technetwork/java/javase/downloads/index.html (JDK), but when I first installed my antivirus Avira did a system scam, I don't remember if it was for java or not, but just pointing out.
I also got a strange error, saying that there is a missing file inside the bin folder (I can't get that error again, sorry folks). When I try to run "javac" on CMD it says "java is not recognized as an internal or external file" (my computer is not on english, sorry), so I went to check and the folder is like this:
As I can see, there is a lot of missing files compared to the guy's videos, and I wonder what could have gone wrong.
I tried:
Doing the rest of the video to see if it could at least works
Running the installer again (it runned completely fine, like if it was first time, but did no stuff). On the first try I got that same error, but lately I haven't got it again
Checked other folders
I can't see to find the solution. Any help?
You need to add the JDK bin to your path. You can do this by going to Control Panel > System and Security > System > Advanced System Settings > Environment Variables > System Variables > path > edit. Then, you need to add this to the path:
;C:\Program Files\Java\jdk1.8.0_60\bin
WARNING: this is highly dangerous! if you delete parts of the path, your computer might not function properly! Be extremely Careful!
Apparently I downloaded the wrong java, my system is 64 bits (which means x64) and I downloaded JDK x86 (which is 32 bits). Just deleting all the JDK and JEK files and reinstalling using the correct one completely fixes it. Remember to use the "path" fix too:
Blockquote
You need to add the JDK bin to your path. You can do this by going to
Control Panel > System and Security > System > Advanced System
Settings > Environment Variables > System Variables > path > edit.
Then, you need to add this to the path: ;C:\Program
Files\Java\jdk1.8.0_60\bin
WARNING: this is highly dangerous! if you delete parts of the path,
your computer might not function properly! Be extremely Careful!
-Ethan Ferguson

CMake can't find Java because of Cygwin

A user of my software is running Windows with Cygwin installed, which provides access to the standard GNU which command. In my CMakeLists.txt there is a line that reads:
FIND_PACKAGE( JAVA REQUIRED CONFIG )
This fails on his machine, because both JAVAConfig.cmake and java-config.cmake (executed by FIND_PACKAGE) use this command as a first-line attack in locating Java. The command returns a bad path to a non-existent install of Java. What can I do to override this annoying behavior from my CMakeLists.txt?
Ask him to send you his "path" env. variable, you will find something interesting there for sure.
Other issue is Java installations.
Ask him to unstall old javas or just update to newest, current installer removes older copies.

Java. Save file as root in Linux

How I can save file generated by java application in folder with root access?
The straight forward way to do that is to run your application as the root user.
Another solution is to ask to the user the root password. To do that, you have to ask the "su" command of your system. Be careful, your user must have the "wheel" group. Or, you can use sudo (make sure that sudo is installed and configured for the current user).
As caarlos0 said in the comments, you can use "kdesu" or "gtksu/gksudo" if you prefer.
Of course, your application is not portable ! On windows, there's no "su", "sudo", etc.

How to use google batch upload in linux

I have read this article
http://lifehacker.com/5354441/google-docs-batch-upload-eases-online-document-transfers
java -jar google-docs-upload-1.2.jar /home/kevin/uploads --recursive
now its not working it says bas command not found.
is java already installed in vps centos or i have to install it
Either you don't have java or its not available in your path. Some linux distros install java in the /opt directory. So be sure to check if that's the case with you. If so then its just a matter of updating your path if not then there are two possibilities :
1. You have root access.
2. You don't have root access.
If you do have root access then you can easily install java with your package manager, if now you can still install java as a local user. Read this to do that. You can install any version of java that you so wish, also it may be unnecessary to install JDK, just JRE might be enough for you.
Don't do the steps that need root access, just copy it somewhere in your home directory or any of the directories to which you have access. Then set the appropriate values for JAVA_HOME and your PATH. It should work then.
If you need any help in doing that feel free to ask.
Download the jar google-docs-upload-1.2.jar.
Ensure you have Java.
Use your own home- and upload-folder, not the "kevin/uploads" one.

Categories

Resources