My application will support only java 1.6 version and I need to execute all test cases using java 1.7 compiled class files code.
My question how to reach above requirement...
Is it possible to install both java 1.6 and java 1.7 versions in my machine?
If possible how can i set java 1.6 path for my application and how i can set path for java 1.7 version to execute test cases using java 1.7 compile files.
Application will not open with Java 1.7, but I need to use java 1.7 compiled files only.
Yes , it is possible. You need to change JAVA_HOME environmental variable. You can set it in the script that is used to start the application.
This article might help you
Yes it is possible.
You can install multiple java versions in single system.
To make it simple. You can use eclipse , or Netbeans IDE. In that you can use different java versions to compile.
Like any program, you need to specify the directory of the program you want to run, either directly by giving the full path name, or indirectly by setting an environment variable like PATH or JAVA_HOME OR JDK_HOME
You can install any number of updates/versions of Java until you run out of disk space. To configure each program to use a specific version you need to look at how they are started and set appropriate directory to use Java from for that program.
Related
Imagine, in my Path variable on Windows 7 I have the path to my jdk version 8 already included. Now I start a new project where I am using Java 11 for example and I add the path to java 11 JDK's bin also to the Path variable. I am wondering, if it is required to remove the path to the (old) JDK 8 in this case from the Path variable for a correct working? If I leave it there, will the correct Java version be picked up for the new project? And also: In my IDE, when creating a new project, I also do select a JDK to use. What is this choice used for and what is the specification of the JDK in the path variable used for? I am not very familiar with operating systems, so please explain it :)
1) the system's path variable
The path variable defines where the system will search for executables you are using on the console/shell.
Having multiple JDKs in your operating system's path variable is a bad idea. One will take precedence and you cannot even (or should not) be sure which one it is.
If you need different JDKs for different projects, you may create a script setting the environment. Let's call it configure.bat for Windows. When opening a shell you would first run that script to set all environment variables and probably start needed services.
Use commands like java -version or mvn version to check the JDK you shell is using!
You may alternatively be able to create the environment settings by configuring an instance of your shell in a different way, but I unfortunately can't give you any details about that.
There is an alternative ...
2) the IDE's path variable
In you IDE (Eclipse, IntelliJ) you can also configure the JDK, and more important: you can configure different JDKs for specific code levels and can set the code level (or the JDK directly) on each of your projects individually. While working in the IDE you don't need to run configuration scripts, the IDE will take care of that. Be careful though, when using a system console in the IDE, you might be falling back to 1) then.
3) Maven
In a similar way as in the IDE you can configure:
JDKs (.m2/settings.xml)
code levels (the project's pom.xml or one of the parent POMs)
when using Maven. For more details see:
http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html
This should be possible for other build management tools like Gradle. I have to refer you to a web search for those, though.
Within one of my application logic recipes, I need to use java during compilation time on the host system. The tool needs java 1.8 and fails to work with the jamvm-native and cacao-native packages.
What I have tried so far is to add the meta-java layer to my configuration and add DEPENDS = openjdk-8-native to my application logic recipe. This makes yocto compile the openjdk-8-native just fine.
Then, when I start a devshell for my own recipe java -version gives me
java version "1.5.0"
JamVM version 2.0.0
I can find the correct java from openjdk-8-native within the recipe-sysroot-native/usr/lib/jvm/openjdk-8-native/bin/ directory, but how can I make it the default java in PATH or use update-alternatives to make my build tool pick it up correctly?
Just for clarification: I do not need java on the target, just a native build during build time of another tool. I'm currently using yocto rocko version.
I'm new to java programming and I haven't used any java IDE,
I intalled Java JDK 8 on my computer and been doing some coding through Notepad++ and compiling it via cmd commands.
Since now that i'm comfortable coding manually, I wanna try to use IDE and decided to get the latest "Eclipse IDE for Java Developers". what I got is actually a .zip file no installation or something which is odd.
My question is does the eclipse uses the JDK I installed on my computer or it has it's own? if so how would I know which version of java does my eclipse run?
and if does use the JDK on my computer, if I want to update the JDK intalled on my computer do I have to uninstall the old one or I can just overwrite it with the new JDK build??
Thanks,
CC
Eclipse uses externally installed JDKs to run itself (it's written in Java, after all) and to provide the core libraries for the code you write (such as the java.* packages). By default, Eclipse will use its own compiler, ECJ, that has deep integrations with the IDE to provide features such as detailed error reporting and sometimes even partial compilation of invalid classes.
It's possible to override the compiler via some plugin (for example, you can explicitly specify a compiler in a POM via m2eclipse, though the default there still uses ECJ), but that's uncommon if you're still compiling Java code.
Eclipse has support for using multiple JDKs, for example for different versions (maybe you have backwards compatibility with 1.6) or different vendors. Depending on how your OS is set up, if your main JAVA_HOME is set through a symlink, you may not need to update Eclipse at all if you perform a minor upgrade. In the case of a major upgrade, though, you will probably need to go to "Installed JREs" and add or modify an entry.
1.the jdk you installed in your computor is global situation. it can effect anywhere if you have configured the environment variables.
2.configured the environment variables,run cmd like this,the java version will be show,enter image description here
3.generally, one JDK , one computor is enough.if you want to update jdk, just download new jdk and override the old jdk .
I have to install a lower version of Java on some clients but some of them have a new version already installed. Do you know which one will take precedence? Is there a way to force Java to use a certain version without uninstalling the other? We have an application that requires the certain lower version.
By client I suppose you mean some Windows machine?
You can control which version is used by setting:
The system path to include the java.exe you want used at runtime.
The JAVA_HOME variable to point to the JDK library, only if development takes place on the machine.
If the client you are using does NOT have the option to setup JDK, then it will look into what ever JAVA_HOME you have defined in your OS environment variable.
There are clients, such as Eclipse, where you can define any version of JDK installed on your machine.
Also, if you are just launching your app using Java (and the app itself is not invoking any Java), you may be able to get away with just setting the shortcut that launches the app:
...\my\path\to\java\java.exe NameOfAppMainClassInYourJar.class
and setting the classpath as indicated here.
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