Provide download link for Java when not installed - java

I'm writing a Java applet for a small game. When a user doesn't have Java installed, I would like to provide some sort of help. Automatically downloading Java is most likely not an option. How would I go about detecting if Java is installed, and showing a OS-appropriate download button if it's not?
Thanks in advance,

Look into JNLP (also called Java Web Start). Here are a couple tutorials:
Deploying a Java Web Start Application.
Deploying an applet
What's nice about JNLP is that you don't have to code anything, it's already been done for you. And it allows for the automatic download of a JRE if it's not installed.

Use deployJava.js to ensure that a suitable JRE is installed (and then it will write the applet element).

Related

Can I run a JavaFX application via Web Start with Java 6?

I want to offer a JavaFX-Application online via WebStart.
Is it possible to launch the application if the user only has JDK 1.6?
If it isn't possible "out of the box", can I somehow include the neccessary jars in the application?
I am pretty sure that Java FX was usable in later versions of 1.6.
It is neither legal nor practical to supply the JRE (or separately Java FX) in Jars.
The best way to deploy a JWS app. or applet is to use the Deployment Toolkit Script.

Java EE -- Configuration issues for a beginner

all. Relative rookie here who has spent the better part of three days just trying to get started with Java EE, and it's driving me up a wall. I've already read through numerous tutorials and consulted several book, so now I am turning to you.
I am starting from complete scratch, having uninstalled NetBeans and Glassfish and the Java EE SDK. My main issue is quite simply configuration. All the resources I've found typically say in a mere throwaway line: "Once you download the SDK, you must configure your environment for Java EE." But HOW? I need it in plain English. Even the most novice guides leave this basic stuff out. Does this mean editing the JAVA_HOME path or what? How does this configuration relate to the Java SE already on my system? Furthermore, I assume I don't need to also download the JDK with EE since I already have a JDK? (I am a Mac user, if that matters.)
I know I have a long, long way to go, so I appreciate any help I can get as I try to get this ball rolling. Much thanks in advance!
I think if you are using Netbeans then you don't have to worry about these things....
Simply File > New Project > Java Web > Web Application will help you get started with web applications..
Normally you would want to set the Java Home path so when you are compiling and running code your JDK is recognized. Sometimes IDEs come with their own JDK and then it really does not matter. However here is how you would set the path in different OS.
http://java.com/en/download/help/path.xml
For MAC I recommend this tutorial
http://lindaocta.com/?p=38
Make sure your JAVA_HOME is set in environment variables (just downloading SDK is not enough, you need to setup), I don't know how to do it mac, but in windows we setup my right click mycomputer-->Advanced-->Environment variables
Then install Netbeans, this step automatically searches for JAVA_HOME and assumes that SDK for all purposes. Then you are all set of programming.
If you don't mind switching to Eclipse can I recomend this tutorial An Eclipse / GlassFish / Java EE 6 Tutorial ignore the referance to Azzyzt tools and run through the tutorial step by step using GlassFish Tools Bundle for Eclipse.

Need Help in Running My Java App

I had created a Java Swing Application, I want to run my applications, in all System, Suppose if a System, does not have JRE, then i have to install JRE using Installer in program without aware of the user knowledgeable that the JRE is installed.
There were a few projects for doing this, but from what I can see they all fizzled out - bottom line seems to be that you need a JRE - especially for swing
The best solution is not to try and install anything silently, but instead to assist the user to install Java. Oracle's deployJava.js was designed to do just that, before embedding applets or launching Java Web Start applications.
While on the subject of JWS, it is also a good choice for installing/running & updating Java rich client (e.g. Swing) apps. on platforms that support Java.
You can generate an EXE out of your Java source but you will still need the JVM to run it on the destination System. So its not real native.
There is no workaround for running non native class files reliably or really at all without the JRE.

Auto startup for java desktop application?

I have created a desktop application in Java using NetBeans 6.1 and made a jar file of the application. Now I want to make it automatically start up whenever a client's machine boots up.
How do I do that?
There are many commercial installers which can do this
http://www.advancedinstaller.com/jre-install.html
Are you looking for a free/OS one?
Thanks
Krishna
This installer can create a file with "msi" extension that will behave as regular windows installer. It bundles your jar file and JRE together into single file. The program acts as a "wizard", where you configure all necessary options.
Take a look at this product:Advanced Installer
Good luck.
If you simply want to have a java application autostarted in Windows you could just create a link in the users autostart folder calling javaw the same way you'd normally call java.
This is just meant FYI, the other suggestions are more general, of course, but this could be the simplest solution...
҉ works
I have found the following order best suite to take a decision for commercial or free one, to fit your needs (most of the following does auto startup + extra features):
Order show more features on top:
BitRock: see features
i would really use this one, because it does all cross platform + Jnlp + Prerequisite
Tanukio: enter link description here
IzPack
Advancedinstaller: features
(optional) Jnlp web start: example (this should become future way of installing)
Please note that, prerequisite is not mentioned, most of there feature list, which is very important to have in all of them, because many case we use third party libraries/dependencies, so the best question would be to know if they support it or not.
Take a look at Tanuki's Java Service Wrapper. The Community version does what you need, plus a lot more.
If you only need to run a Java program periodically, I like pycron, which installs itself as a Windows service and then reads a Unix style crontab file where you would enter a line that tells pycron when it needs to run the java process (eg, every night at 3am).

Dynamically loading a native library inside Java applet

I am trying to write a Java applet that will read from a user's serial port. For this I am using the Java Comm API in conjuction with the RXTX library. I've successfully managed to read data through a local Java application but I can't seem to do the same from within an applet. The problem is that the RXTX library is a native library and I haven't found a way to load this library inside the Java applet. I've found two interesting articles (Using JNI in Applets which references to this article), but both are over 10 years old and I am wondering if there is a newer solution. Or if you can suggest an alternative, I would love to hear it!
Use Java Web Start. You can include the native library as a signed jar and everything should work.
1) put the native librarys in a jar in the ROOT directory
2) sign ALL the jars
3) write a JNLP referencing all the jars (go do a search on how to write jnlp's)
after that it should work
Firstly I'd suggest doing that in an Applet is probably a bad idea.
If you do go ahead anyway, JNLPAppletLauncher may help.
I don't know about applets, other than they're locked down heavily wrt. security/accessing the machine's resources etc.
If you need a web-deployable solution, have you looked at Java Web Start ? See in particular this FAQ entry
Frankly, trying to access devices from a Java applet is a bad idea even if you could make it work, and loading a dynamic library into the conventional applet is an even worse idea; in fact, I'd be astounded if you could find a way to trick a modern browser into doing it. (Consider the possible security implications.)
You're better off, as suggested on other questions, building an app that can be launched with Web Start.
I'd be real interested in the answer here also. My suggestion would be to install the .jar and .dll for RXTX into the \program files\java\ tree. You could install them on the target system before trying to use the applet. I like the idea of using Java Web Start. If you sign the applet, can't you read/write any file on the machine? So you could install the .jar and .dll and then use them afterward?
For windows, I suggest using "Windows Java Serial Com Port Driver" rather than rxtx.
You can download it from http://www.engidea.com/blog/informatica/winjcom/winjcom.html
I've found it much easier to install and use and much more bug-free.
I was unable to use RXTX with USB serial devices because RXTX would crash when the USB port was unplugged. winjcom solved these problems for me, and more.
I'm still trying to decide how to deploy the DLL, but I'm not sweating it because I don't expect the DLL for "Windows Java Serial Com Port Driver" to change.
-Stosh

Categories