Running Multiple Java Versions - java

Hopefully someone can help me because I am apparently brain dead. I have searched and read through a lot of this forum as well as others for help in resolving my problem and I am just not getting it.
I have 2 Java WebApps that I need to run for Johnson Control HVAC units. The one unit is old and strictly requires Java 1.6.0_21. There are no upgrade options available for this unit. Just hundreds of thousands of dollars to replace the whole system. But the system works just fine so I am not interested in replacing it.
Now I have another unit which my company just took over at another location that uses a similar control unit but runs on Java 1.7.0_49 or 69 I can't remember. I have both versions installed on my computer but only the newer unit with Java 1.7 works. My older one now comes up with Unable to Launch Application Error. I have tried all these things and either I am just plain doing it wrong or something else that I am not catching is up.
I tried going into the Java Control Panel and unchecking Enable 1.7. That had no affect, even after rebooting.
I went into the Environmental Variables and under Path I have no Path to Java. So I added the path to the Java 1.6 version which also had no affect.
I have a batch file on my desktop to run the older app because it's web URL is a mile long. In this batch file I tried to add set JAVA_HOME variable and a set PATH variable for Java 1.6 which also had no affect.
I tried just doing java -version:1.6 from the cmd prompt which also did not allow the program to start.
I got it so when I did java -version from the cmd prompt it would tell me 1.6.0_21 for the version but I still can't get the program to load.
So I uninstalled 1.7 from the computer and tried it again. Still would not load the program. I had to reinstall the 1.6 before the older program worked. But once I reinstalled 1.7 I was back in the same boat.
I tried re-installing both programs using the STATIC=1 command through cmd prompt and still only version 1.7 runs and the older 1.6 does not.
I do get a message when I try to load the 1.6 that says, the program has requested an older outdated version of the program. Open with new version recommended or open in the older requested version 1.6.0_21. I select open in the older version but still get the Can Not Launch Application Error.
I have also tried going into the advanced settings and unchecking Internet Explorer for the Browser in the 1.7 control panel and going into the 1.6 control panel and checking Internet Explorer.
What am I doing wrong here or what am I missing? Any help would be appreciated.
This is a Windows XP 32 bit computer. Nothing special, just a word processor mostly.

You are swimming upstream, but it isn't a very large or strong stream, and this can be done.
The upstream part is that most instructions for doing this assume you are going to run only one version of the JVM on a given machine.
The good news is that Java doesn't require this, and is not set up so that it is difficult to run two at the same time. You just have to be rigorous about where each of them get their information.
I would recommend not "installing" EITHER of them. Do not put the executables' or the libraries' directories on your path variable, and do not define a CLASSPATH variable on the machine globally. You will need to unpack a runtime environment for each JVM, each in their own directory tree.
Make one batch file to run each version. It will define its own path variable, and its own classpath (either with SET CLASSPATH= or using the classpath JVM argument).
Good luck.

Related

Running ECLIPSE on a memory stick

I'm trying to run Eclipse (Neon 1) on a memory stick. In a first time, the problem was the JVM 1.6 installed on the machine which is too old. To use a compatible JVM, I created a jre directory in Eclipse's directory and placed in it a JVM 1.8 (the last one found on ORACLE's web site).
Now, when I try to run Eclipse, nothing happens. I got the splash screen with "Eclipse Neon 1" then, nothing, not even an error message.
What is the problem and what can I do ?
Important note : I can't install a JVM on the "native machine" as I'm not administrator.
Than, you for all your answers. Have a good day.
When you need programs to run off a USB, always search if a portable version exists first. This is a working portable version of Eclipse Neon but it is another version though.
Finally, I found (one of) my mistake.
I used a jre(...).exe. It's the problem. I downloaded the tar.gz file of the jre and unpacked it. Then, I used the jre of this unpacked version and everything was ok except a problem with an "access restriction" to some libraries.
I fixed that last problem with that question on StackOverFlow. And now, everything is ok !
Great ! Thank you to everyone for your help.

Java application not working on other systems

I've made a word-processor named StoryTeller in Java (a first - beta version, which I'm still working on improving) and put it online for others to test out and use.
I've gotten a response saying they were unable to open it. I've built and run StoryTeller on Windows 10 OS and it works fine. After generating the jar file, I used Inno setup to generate an installer for the program. You can find the file I've uploaded here. Here's the message I got about it:
Hello! I was going to try out StoryTeller on my Macbook today, but unfortunately it didn't work. The file automatically gets opened in
"Text Editor" where encrypted text shows up along with the error
message "this program must be run under Win32".
I downloaded it on my old computer earlier this week (it has windows
7) and the download process and installation worked perfectly fine,
but I was unable to open the program when the installation was done.
It appeared on my desk as a Java-symbol (the icon) and nothing
happened when I clicked on it. Both my OS are quite old (Macbook from
2010 and the other computer from 2012), but I've still updated them as
much as possible and installed all the latest versions available of
necessary programs, so I'm not sure whether the problem lies within my
computers or StoryTeller itself.
Do you have any ideas how I can fix this? I would really like to try
StoryTeller since it seems to be a great concept that could really
come in handy when I work on my novel.
Could anyone help, please, understand what may be the issue here? Thanks.
First, check if your JDK is 32-bits and make sure to advice your future users have a 32-bit JRE installed. This way, it may work properly. I think 64-bit Java apps can't run atop a 32-bit JRE;
You can bundle a proper JRE/JVM with your software;
Make sure you are referencing ANYTHING with absolute paths inside your code. This could make your software throw several exceptions when running somewhere else;
For instance, Inno-setup commonly generates Windows-only .exe setups. Installing your software in a Mac would require you to generate a .dmg or .pkg (this one you could create through PackageMaker extension from XCode here (require registration, more info here
Kappy on Jul 5, 2012 6:28 PM says: Go to connect.apple.com and search for "packagemaker." Of course you must first be logged into your developer account.
))
For Linux, you can provide a simple shellscript bundled with your .jar (even with a discrete JVM) in a .zip or .tar.gz file, and ask your future users to run the provided shellscript.
Good luck!

Error Could Not Find or Load Main Class

Using NetBeans IDE 7.3.1, I modified a desktop application under Windows 7, using JDK 1.7. Performed clean and build, and tested this application under Windows 7, Windows XP, and on a MAC. All test scenarios run under each operating system performed as expected.
This app is ported to outside vendors, and all vendors, except for one, have loaded and executed the app without any issues.
The one vendor encountering problems, and running under Windows XP, returns an error message - "Could Not find or load main class". After doing a little research, this error usually indicates the JDK is different. They downloaded and installed JDK 1.7, but the same error message appears. I had them go to http://javatester.org/othertesters.html, making sure that java was working on the workstation and verifying the java version (1.7). They reinstalled JDK 1.7 and still receive the same error.
I have duplicated the error by removing JDK 1.7, loading JDK 1.6 and running the app. Receive error ("Could Not find main class"). A little different than what they receive, but basically the same problem. Removed JDK 1.6, loaded JDK 1.7 and problem disappears.
I'm at my wits end! I am going to make an appt. to access their workstation. But before I do, I would like to put a plan in place to try different scenarios to fix the problem. I don't know how to proceed, since I've run out of options. I'm hoping for any suggestions.
OK,
Problem solved. Sent application via outlook, modifying executable file from .jar to .txt b4 sending application. I didn't think about looking in compressed LIB directory. Four files were .jar files.
These files were quarantined. Renaming these files to .txt b4 compressing app would have eliminated the problem. Resent the zip, vendor extracted and renamed all .txt files to .jar. All is well.
Appreciate everyone's input.
I believe they still have a JDK 1.6 on their machine and use this, for some reason, to try to execute the application. I've seen this various times at customer workstations.
Very often, people are not aware of what they have installed. Tell them to remove all JDKs and JREs from their workstation, by way of uninstallers and looking into the program folder and deleting stuff manually. Tell them how to do it. Do this with them during a phone call.
Then have them reinstall JDK 1.7. I'm almost sure it will work afterwards.
Alternatively, you can compile the application for older JDKs. You can also do this using JDK 1.7 by setting the target version for the classfiles.
Make sure that their JAVA_HOME path is pointed towards the JDK 1.7 install. I have had similar issues where I had multiple JDKs installed, needed to use the latest, but the computer was pointing to an older version.
To find what version the java_home is type java -version in the cmd.
How to find java_home: How do I find where JDK is installed on my windows machine?

Get a Java program to run on a computer without modern JRE

I made a simple text based game that runs on my computer, but my schools computers have an older version of java and can't run it. I tried compiling the .java file in from the computers command prompt but I can't access where the javac folder is to compile because the school computer blocks everything. The command prompt is even disabled by the administrator unless I open it with a batch file. I tried wrapping the jar with the JRE in Launch4j but the exe does nothing, it loads and that's it, nothing comes up (I think it's because the text game is supposed to run in the command prompt so there is no GUI to print any of the text)
How to get a Java program to run on a computer without modern JRE?
my schools computers have an older version of java and can't run it
Use the cross-compilation options of javac when compiling it at home.
You are running into a bit of a contradiction here; Please take notice on what exactly you are asking:
"How can I run a Java Program without Java?"
Do you get it? You are basically asking "How can I drive a car without the car?"
As for the actual problem, all hope is not lost. Here are some options:
If possible by any means, simply install the latest stable version of Java on the machine.
From a computer that has JRE/JDK installed (or through another form of access to the JavaCompiler, AKA JavaC), recompile the code to the older version of Java using the command-line parameters for source and target java versions (Note: I am unsure if the JRE/JDK for the older version must be installed in the machine or not).
For this case, you might want to take a look at this and/or this.
Choose another language to work with, and re-do your code into that language; You can't run Java code without Java, the same way you can't travel by train without the train to travel with.

issue with java and environment variables on windows

I've got a curious problem. After installing java jdk 6u25 I tested the installation by typing java in the command prompt. Everything worked fine , the console displayed the usage options as expected. This was about 3 weeks ago - I recently reinstalled windows 7 on my machine- Now I would like to get started with the play framework and followed a tutorial. I got a new application with play new but couldn't use play run because of this:
play! 1.2.3, http://www.playframework.org
Ctrl+C to stop
Could not execute the java executable, please make sure the JAVA_HOME environment variable is set properly .
The funny thing is that typing java in the console still displays usage options and neither eclipse or netbeans complained about a missing jdk. Nevertheless I checked my environment variables and was surprised to find:
No reference to java at all.
Seriously I got no idea how the console, eclipse and netbeans found my java. As a first countermeasure I once again reinstalled java hoping that the installer might set the path correctly. It didn't. Now I would like your advise: Should I just create the JAVA_HOME variable ? If I do, will further versions of the jdk override the variable to point to the new version or will I have to change the variable manually everytime? What about eclipse and netbeans. I would guess that they have been downloaded with their "own" jdk. If I want to update java on my machine, will it update their versions, too ?
Update:
I set the environment variable manually and restarted the pc. Now everything works fine but I would like to know what symbolic link is. Could you just give me a link in a comment or explain briefly ?
Eclipse and netbeans use a different way of finding your java installation than command line tools likes play, ant, maven, gradle etc.
IDEs may search your registry, guess default locations, or even have the JRE prepackaged with the installation.
Command-line tools usually rely on JAVA_HOME variable. And you have to set that manually.
Should I just create the JAVA_HOME variable ?
There are several tools that use that environment variable, so I'd recommend creating it.
If I do, will further versions of the jdk override the variable to point to the new version or will I have to change the variable manually everytime?
If you install your new Java version into the same folder (or if you create symbolic links), then no.
What about eclipse and netbeans. I would guess that they have been downloaded with their "own" jdk. If I want to update java on my machine, will it update their versions, too ?
That depends on whether the JDK is prebundled and how the configuration is done. I can't speak for Netbeans but in Eclipse, you could add this to your eclipse.ini:
-vm
C:/Java/jre/bin
Note that this is an example path to the bin folder. If you don't add versions there or use symbolic links (see above) then you'd not have to update the path when installing a new version.
It is possible that you have a (older?) java.exe in C:\windows or other common directory.
Make sure that the java you get on the command line is the one you think it is:
java -version

Categories

Resources