I'd like to write a desktop app using Java and I'm wondering if I can get the app to execute on computers running both Window 7 and Windows 10. I've got Eclipse set up with JavaSE 1.8 and I'm running Windows 8.
Thanks!
Yes. Once it's compiled, you can pass your app on to any computer with a JVM (Java virtual machine, aka "any machine with java installed") and your application will be able to be run. There are versioning caveats, for instance an old version JVM won't be able to run newer code (compiled to a higher version) but you probably won't have to worry about it. If you need to, you can set your compiler to compile to earlier versions (and you can set this in eclipse) but you probably won't have to bother with it.
Related
I've been working with Java for a bit now and the JDK/JRE version has given me quite a bit of trouble lately. I am developing using the Intellij IDEA IDE and it of course uses the latest version of the JDK, 14. However when I attempt to execute software compiled with JDK 14 outside the IDE, I get an error that the JRE isn't new enough to run this software. So I updated Java on my computer and another machine and attempt to run again without any success. After some digging, I tweaked my machine to use the JRE included in the JDK 14 which is compatible.
However it is kind of odd that I had to do that, one would think that the latest version of java should of been enough to run applications made with the latest version of the JDK (14). Right now Java is version 8 build 251 and says there is no newer update available. If JDK 14 is out for a while now, why would they not update the version of Java they ship?
The problem is partially solved, as only the machine I am using for development is capable of executing the created applications. Other people I've sent them to have been unable to run them, despite having the latest version of java. Also it is a pain to get the latest JDK, especially when having limited experience on how to get rid of old versions, change path point to the latest version, get the right package (open/oracle JDK) and do that for windows and several distrubutions of linux. What is going on? Did I get Java from the wrong place and everyone else as well? Why are oracle doing this and why are there no java updates since clearly there exists a newer version?
Starting with Java-11, separate JRE does not exist anymore. In other words, if you are using Java-11 or above, you should care about JDK only.
You should uninstall JRE-8 from your machine and make sure your JDK-14 bin folder in the PATH variable. Some application even requires JAVA_HOME to work and therefore you should make sure that your system has an environment variable called JAVA_HOME and its value set to the root folder of JDK-14 (i.e. one level above your JDK bin).
Q: What should my clients do to run my application compiled on JDK-14?
Ans: Your clients must install JDK-14. Also, check this thread for some alternatives.
You're confusing how IntelliJ or JDK are used on the OS. IntelliJ, now, often comes with its JDK binaries (but even this can be configured, IntelliJ can be configured to use any JDK/JRE build you'll provide to it); however, if you run your Java application out of IntelliJ, most likely you're using Java installed locally on your OS, which might be referenced via your JAVA_HOME environment variable.
I'd suggest to:
Check java -version in your shell (and hence you'll see what JVM instance your OS spins up when you run a Java application);
Check where java (on Windows, or which - on Linux) in your shell, to see all the Java binaries available on your OS.
Try to uninstall Java SE Development Kit and Java JRE(if you have both in your machine) and reinstall both again, JDK and JRE both, I am sharing my google drive link where you can find the latest version of both JDK and JRE and when you are done installing, add there bin folder path in the Environment Variables of your machine.
I am not native English user and I am sorry for bad English but very interested in programming.
My question is: Has every program that is installed on a specific OS a separate compiler or all programs that are installed on that OS use from a default OS compiler?
Thanks.
Your question is marked with 'java'. Regarding Java
you must have JRE to run a java program. JRE stands for java runtime environment, which includes JVM (java virtual machine) and another runtime units. Java feature is to have single JRE to run every java program (let alone versions etc). JRE will execute java program.
if you want to create a java program on your computer, you should have have Java SDK (software development kit). It includes compiter and huge bunch af another necessary and useful tools. SDK can turn your java source code to an executable java program.
If the question is general, like, what happens when you install a desktop app, it depends of a app type and it's installer type.
There are some, that are distributed with sources and are to be compiled at the installation phase right at your machine. Most often they have anything they need to run the installation successfully, including all necessary compilters. In vast majority of cases you are not supposed to have something preinstalled on you OS prior to the program installation.
But mainly a program is distributed as a bundle of binary artifacts. They are already compiled and packed and are delived in this state. So no, here you are not expected to have a compiler on you machine.
I'm developing in Eclipse in Java and I noticed that the software execution in my eclipse is much slower (like 6 or 7 times) than the same code run in eclipse in another similar pc (both have 8gb ram 8 cores). The only difference is that I'm running on windows 7 and the other pc is running ubuntu 13.04.
I already checked and I'm using the right virtual machine (jre 1.7, the linux one is with jre 1.6) and there are at most about 20 prints on the console over a 6 minute run. Also I'm running as "run" and not debug.
What can it be? Is it possible that under linux is much faster?
UPDATE:
I installed a partition with Debian 7 on the same laptop with windows (where it was running slower). With both the default open jdk 1.6 and the new java 1.8 Debian is much faster. I would say ok if it was like 2 times slower, but a 6 minute execution instead of a 1 minute one is a bit strange.
Linux is in fact faster (usually) than Windows. It depends on alot of things though, RAM and cores are not only things that matter. CPU architecture, clock speed, OC or not and so on. If you´d post both computers specifications then it would be easier to answer but until then there's your answer.
One thing you can do is use a Terminal on each platform:
First do a java -version to make sure both are really using the Oracle JVM (for example, on Ubuntu, a trivial installation of Oracle JDK may not guaranee that you're not still using the original Open JDK).
Then, run your Java program in the terminal on each machine, and see if the difference persists. If it doesn't (i.e. if you only have the big performance gap when running from Eclipse), then it might be Eclipse's fault. While Java does tend to be faster on Linux/Debian vs. Windows, Eclipse might not have the same trend. If your experiment shows that Eclipse is the reason for the performance gap:
make sure that Eclipse is configured to use the Oracle JVM on each platform
make sure Eclipse itself and all it's possible plugins are updated (and if not, update first Eclipse, then its plugins).
This question already has answers here:
Multiple Java versions running concurrently under Windows
(10 answers)
Closed 9 years ago.
I was wondering if there would be any implications (slowed performance, crashes and so on),
running a java 1.4 application and a java 1.6 application on the same machine
Different java version are installed in different directories so running 2 java programs with different JRE version will not make any effect other than that you are running 2 processes of java.
So bottom line, there is no problem with that, it will not slow you down.
Also, java 6 has better performance than 1.4 so if you can run both on 6 its usually better.
None, The only problem is you can only have one default JVM. If you have too many versions e.g. hundreds it is likely to be a bit of mess, but it won't slow you down.
It seems that the header does not correspond the question. Running different jre versions on the same machine is not the same as running a java 1.4 application and a java 1.6 application. So I will give 2 answers
Yes you can have 2 different jre installed on your machine.
You can run 1.4 application (classes compiled in Javac 1.4) on JRJ 1.6 but you cannot run 1.6 application (classes compiled in Javac 1.6) on JRE 1.4.
Of course, It will not slow machine. A machine can have multiple JVM on single machine. There will not be any kind of conflict because everything would be in separate folder.
There is only special case in case of multiple JDK/JRE.
Case : - What version will be used by your browser.
For this you can control all the things from java console from control panel in windows.
Yes, you can have multiple JRE installed on the same machine on the same O/S. And you can have one project configured with one version of Java Compiler on your IDE. But remember when you run Higher version of Java compiled code on a JRE having lower version, you might face some issues with the new features and enhancements introduced with the later versions.
In my ini file for winrun4j java exe wrapper I set vm.version.min=1.7 to specify Java 7 as a requirement. But when I ran it I couldn't get winrun4j to recognise that I had a java 7 jre installed even though java -version from the command line returned it.
On further investigation I realized that my Java 7 installation was 64bit whereas my Java 6 installation was 32bit. I then found that winrun4j has some 64bit version of its commands (ie rcedit64), if I built an appname64.exe rather than appname.exe it no longer complained about Java 7.
So can someone confirm this was the issue that I need a 64bit exe to run a 64bit jvm
Secondly if this is the case how do I present this to the user, I'm wrapping the installer as an exe so does that mean I need to provide the user with both an installer.exe and a installer64.exe and explain to the user to pick the right one not based on their processor but based on what version of java they have installed32bit or 64bit)
Edit:
Sounds like things are as i described, and using launch4j maybe a solution
What's the best way to start Java applications on Windows 7?
that I need a 64bit exe to run a 64bit jvm
Yes. You can not use a 32 bit exe to run the 64bit JVM
Secondly if this is the case how do I present this to the user, I'm
wrapping the installer as an exe...
Don't. Just create an installer for a 32-bit system and a 64-bit system. Depending on the target system the corresponding installer should run