Can't run JAR file - java

I have a finished program that I created a JAR executable from (I created this in eclipse), and I need to download this executable onto computers different from the one that I wrote the program on.
However, I am getting the problem that when I try and download the executable onto the computers, I get the window that pops up that says that "Windows can't open this file" and it then gives me a list of programs that I can open the file with, none of which I can use. I do not need to do this on the computer on which I wrote the program. When I double-click the executable on that computer, the program starts without any trouble.

In order to run Java programs, you have to install the Java Runtime Environment (JRE). The Java Development Kit (JDK) is not needed. You can download the latest version (JRE) here.
If you want to learn more about JVM, JRE and JDK, you can read the answer to this question.

This is cause you need install Java in the remote machines including the JDK, then also you need to make java available through console installing Ant wherever it applies.

Related

Running standard exe from java .jar file on clients computers

I have a program that I want to run as an exe on a clients computer. After I made my program in Java I used Jsmooth to create the exe. The program runs perfectly fine from my own local computer, but when I try running the same program on another computer the program prompts me to install Java. After installing Java, the program STILL wants me to install Java. I thought it might be different versions of Java, but I compiled the Jar with the most LTS of Java, and my JRE was on the most recent version. What should I do?
JVMs are quite large. Out of the box, JSmooth therefore doesn't include one. I think you can ask it (I'm recalling exe4j perhaps, a different tool that does the same thing as jsmooth), by stating which path contains one relative to the executable. You cannot fold it straight into the exe, though. It'll then be an installation process where you end up with:
C:\Program Files\AnthonysAwesomeApp\Anthony.exe
C:\Program Files\AnthonysAwesomeApp\jre\lib\rt.jar
C:\Program Files\AnthonysAwesomeApp\jre\bin\java.exe
... and the other 5000 files of a JRE installation
Where 'Anthony.exe' is made by JSmooth, and you told JSmooth that it should use the JRE found in location ".\jre".
That should probably still work.
The more general problem is that the entire deployment model is more or less obsolete; JREs do not exist anymore, at least, oracle/team openjdk has ceased producing them and has ceased mentioning the very concept, but some third party deployers such as Azul still produce them. Java1.8 is the last version that can truly be said to have had the concept of a JRE.
A JDK is a superset of a JRE (It has everything a JRE has, and more), and JDKs still exist, so you should just be able to ship an entire JDK.
The new model is jlink, modules, and treeshaking, and it doesn't feel like any of the exe maker projects such as JSmooth have been updated for it. In general, java is used a ton on servers, but java on the desktop is not observed that much. If you want to delve into those - you have a lot of reading to do, and the experience is not as smooth (heh) as JSmooth.

How do portable Java programs run the JVM from a subdirectory next to the binary?

I have been programming in Java for several months, one of the tools I use is Eclipse, which seems to be able to run standalone from any local Java installation by having the JDK/JRE in a directory next to the main binary.
I have run it from my USB-drive in computers without any Java Runtime/Framework/other... And it has been able to open itself, understand the Java code, compile it, and run it without any problem.
So, the question is How do they do it?. At least in the Windows version (Did not try in the Linux version but I think it might work as well).
See following threads.
https://www.eclipse.org/forums/index.php/t/264351/
How does Eclipse compile classes with only a JRE?
Do I need to install Java SDK if I have eclipse
The eclipse.ini file will point to the local vm location
https://wiki.eclipse.org/Eclipse.ini

How to make an exe file from Netbeans java project to run in all system which don't having JVM?

I have created one webcam application using netbeans IDE and java. then i converted that project into .exe file using launch4j software. that .exe file is running only on the systems in which java is installed. otherwise it shows an error JVM finding error class file is not available.
I want to make .exe file which will run in all type of systems.
tell me some suggestion. I am waiting
There's no such thing as a .exe which will run in all systems, if by that you mean running on Windows, Mac, Linux, et cetera. Java is only portable (without recompiling) because it has the JVM as a layer insulating it from the details of the machine and operating system.
It's possible to bundle the Java Runtime Environment (JRE) with your Java code and ship it that way; you'd build an installer the same way you do for other .exe programs. But you'd need a separate installer for each platform.
There are also compilers that produce native code (.exe files or their equivalent) from Java. Again, that means giving up portability and having a separate version for each platform... and trusting a compiler that probably hasn't been thru the Java compatibility certification. (Plus giving up hotspot optimization.)
You can't run a java application without JVM installed. That's for sure. Other than that ,do you have any questions?? :)

Java Browser Plugin Or Manually installing Java

Here is my question i installed Java Plugin for Chrome it does mean i have installed java in my machine...And after installing this plugin can i run below command
java -jar myfile.jar
through a batch file or i have to install java in my machine and setup class-path then it should work?
If i will install Java browser plugin it automatically installed java in my machine and setup path as well.
Its hard for me t understand the situation how it works. Can anyone help me on this?
The JRE is the Java Runtime Environment, i.e. the software you need to interpret and execute Java class files. The Java browser plugin is the bridge between the JRE and the browser, used to run Java classes of applets embedded in HTML.
You can check the Java plugin of Chrome browser in this link.
The plugin is bundled with the JRE, and runs inside a browser, allowing Java code to run inside the browser process on the client. The main entry point class must be written as an Applet when the plugin is used, but all the Java code it calls can be just regular Java.
There are limitations when running Java code with the Java plugin for security reasons. All code shall run within sandbox with limited access to the file system and such.
Also as the plugin check for installed JRE version at your machine, that means you do have JRE.
You can install as many JDKs as you like. Just put them in different folders.
The one you refer to on the path is your choice - but presumably you'd choose the one that you want to use whenever you type "java ...." commands at the command line. In the absence of any other factors you should probably set this to be your most recent JDK version.
Note that your IDE may support multiple JDKs, for example Eclipse has "Preferences / Java / Installed JREs" where you can set up multiple JDKs/JREs for use with Eclipse
Please first check your machine contains java (jdk or jre)
java -version -- if you get a valid output then you have java in your machine.
in order to run java -jar myfile.jar , you should install java (jre or jdk) in your machine and class path set to the relevant location. To run this you should install jdk or jre in your machine. Most program only need the JRE (Java Runtime Environment) but some programs need the Compiler at runtime in which case you need the JDK.
Please refer this link to find out How to set class path .
Then you will be able to run your command.

Any way to run an exe made from jar using exe4j from another computer?

I've made a little GUI program to enter contents then send "javamail" to my email. I have to import many jar libraries from javamail-1.4.5 and then I build it (shift + f11) to jar, then use exe4j to make it exe (also add all the jars from the libraries in the /dist/lib) and version of jre from 1.5 to 1.7 (I'm using 1.7 to make this app). It works smoothly on my computer but when I give the exe to others computer. It said:
"No JVM could be found on your system. Please define EXE4J_JAVA_HOME to point to an installed 32-bit JDK or JRE or download a JRE from www.java.com"
I think they must install the JDK in order to be able to run the app. But it may be confusing to many of my friends who don't know about computing. Is there anyway can they use that send-javamail-app without asking them to install the JDK?
Thanks in advance and sorry for my English!
It's quite simple.
After you have done basic steps as set the name, icon, etc, in step number 6 JRE is where the magic happens:
Click Advanced Options and select Search sequence
Click to add new item + and select directory
Select your jre directory, it must be a relative path
Put your new item at the first position in list
After that what you have to do is release your exe with the jre directory together, to do that usually I use Inno Setup Compiler to create a installer.
You can bundle the JRE with your product, this is the best way you can achieve without bothering your buddies. The size of your application will increase.
JRE is required to run any java application.
Hope this helps.
Java Runtime Environment (JRE) is required to run the Java application. In order to install JRE on a computer without Java installed, you must either bundle it (put it inside your application), or ask your friends to download JRE.
I don't know exactly how to bundle JRE, but the question Bundling the JRE with a Java application can probably help.
Maybe my personal project Java Customization Builder can help you, it analyzes the classes used by your program, and slim these classes from jars, and it also analyzes jvm files used by your program. Then it make an executable file and pack200 the jre runtime and your program.
JCB Project Introduction:
Java Customization Builder is a tool which customizes your java application and JRE.
It is a java application building tool enabling you to generate a very small java archive package which has a slimmed jre. For the swing application, the archive is less than 5M, for the SWT application, the archive is less than 3M usually. And the customed java applicaton can run on the Windows which doesn't install a JRE, and be loaded by an executable.
JCB project page: http://jcb.sourceforge.net

Categories