How top set java 7 compiler at windows 7 - javac

I have installed java 7 on my machine.
java -version shows that:
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)
javac -version showing
javac 1.6.0_10
When I am trying to build application using Ant it showing me error of "it is recommended that the compiler be upgraded"
How can I update path of javac to point java 7, my JAVA_HOME and PATH variable contain C:\Program Files\Java\jdk1.7.0_09 and C:\Program Files\Java\jdk1.7.0_09\bin respectively.

Try one of the following:
1) Change the PATH. Set JAVA_HOME before the windows paths. This is because under the windows folder, there is a java.exe that redirects to the last installed jre.
2) Regedit. The key HKEY_LOCAL_MACHINE->SOFTWARE->JAVASOFT->Java Runtime Environment contains the last installed version that the java.exe in the windows folder redirects to. If you change this to the version you want, everything should be ok.

Related

Build Android apps on TFS 2017 using Android Studio OpenJDK?

I want to build Android apps on a local TFS 2017 build agent - local TFS 2017 server also.
Android Studio now contains OpenJDK but I couldn't get the TFS 2017 Gradle task to work without installing Oracle's JDK. I tried creating a JAVA_HOME environment variable, using the set JAVA_HOME by JDK version in the TFS Gradle task, and the set JAVA_HOME by path in the TFS Gradle task.
Looks like having Oracle's JDK is the standard for TFS (it's installed on Microsoft's hosted build agents) but I'd like to do without because of the incoming JDK 8 licensing change.
Unfortunately you have to install the Oracle's JDK first if you are using windows build agent, it's one of the prerequisites.
Before you set up Android Studio, be sure you have installed JDK 7 or
later. The Java Runtime Environment (JRE) alone is not sufficient.
Even with the Linux agent, when you running OpenJDK, the installer will tells
"SYSTEM HEALTH OpenJDK shows intermitten performance and UI issues. We recommend using the Oracle JRE/JDK" Reference this similar thread: Can Android Studio use OpenJDK or does it require Oracle JDK on Linux?
More information you can reference below articles:
How to install the Android SDK on Windows, Mac and Linux
Digi Embedded for Android > Get started > Step 4: Create your first
application > Step 4.1: Install the software
The Gradle task doesn't like a JDK path containing spaces. I couldn't get any kind of quotes to work and 8.3 name creation is disabled on the build machine.
I've created directory links with mklink /d for the 2 directories that have spaces in their names. Then in the Gradle task advanced options selected set JAVA_HOME by path and set the path to C:\Program-Files\Android\Android-Studio\jre Works fine now.

apache ant runs properly but ask me for some other things also

When I use Apache-Ant following :
ant -version
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.8.0_111\lib\tools.jar
Apache Ant(TM) version 1.10.1 compiled on February 2 2017
However, it works properly but why it shows this and how can I resolve this?
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.8.0_111\lib\tools.jar
It is because, you have installed JRE while it is required to install JDK.
Please refer System Requirements of Ant
For the current version of Ant, you will also need a JDK installed on your system, version 1.4 or later required, 1.7 or later strongly recommended. The more up-to-date the version of Java , the more Ant tasks you get.
Note: If a JDK is not present, only the JRE runtime, then many tasks will not work.
So, install JDK and
set JAVA_HOME correctly
add %JAVA_HOME%\bin to PATH

Dart editor can not locate java vm

I would like to check out Dart. Got the windows 7 & 8 zip. Unziped it and fired up the editor.
complained that it needed a java vm. Downladed and installed it and set the reference in the ini.file to the Javaw.exe as instructed here:
-data
#user.home\DartEditor
-vm
D:\\Program Files (x86)\\Java\\jre7\\bin\\javaw.exe
-vmargs
-d64
-Dosgi.requiredJavaVersion=1.6
-Dfile.encoding=UTF-8
-XX:MaxPermSize=128m
-Xms256m
-Xmx2000m
still no joy:
UPDATE
went to 64 Bit java version:
I completely removed all java versions and obtained the latest version for windows 8.1,
added the file location to path and voila.
If you have downloaded the 64bit DartEditor you need a 64bit JRE/JDK.
https://www.dartlang.org/tools/editor/troubleshoot.html

Switching between Java Runtime environments

I have both Java 6 and Java 7 installed in my computer running Windows XP sp3. I have entered path in the environment variables (PATH, JAVA_HOME) in My computer-> Properties. But when I give
java -version
I still get the following text
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build
1.7.0_09-b05) Java HotSpot(TM) Client VM (build 23.5-b02, mixed mode, sharing)
However, when I try
javac -version
I get
javac 1.6.0_03
How can I change the runtime from Java 7 to Java 6? When I compile my program in eclipse using ant, I get the following
Warning: java\util\List.class(java\util:List.class): major version 51
is newer than 50, the highest major version supported by this
compiler. [javac] It is recommended that the compiler be upgraded.
Path has the JRE first, thus the java -version and the JDK second, thus the javac -version. Check your PATH variable.
If you want the JDK version, put it first on the PATH.
If am not mistake java 7 windows installer of JDK or JRE will copy java.exe to some windows common path. I don't remember exactly the path but maybe C:\Windows\System32. Try this on command line to know where is the location of java.exe:
where java
Update your path precedence accordingly.
When you install Java (JRE), it copies java.exe into C:\Windows\System32, in addition to installation directory under C:\Program Files. But when you install full JDK (with compiler), it doesn't do that for javac.exe. When you have multiple versions of java, the last installed one will be called when you type java in command line.
Use full paths if you need to have multiple Java versions, you will always have problems trying to use unqualified java in command line. Alternatively, re-install JRE 7 - that will force default java to be V7.

Execution of Java program

After searching all over the web, I am not able to solve my problem of Java execution. When using command prompt to run my "first" Java program, I am faced with the errors of Unsupported class version and Main class not found. Program will exit.
I have 2 versions of Java on my PC, Java 6 and 7. I have set the path of the JDK 7 in path environment variables and classpath too. I know the problem: I have javac -version as 1.7.02 and java version as 1.6.02, but how to change it and fix the problem?
Please elaborate the problem in easy and understandable language!
You have to run your program with the same or higher version of java that yxou compiled it with.
So you can either compile your program with Java 6 on your PC or run it with java 7.
To run your program with java 7 just use the complete path to your java runtime environment. for instance
c:\jdk7\bin\jawaw.exe yourprogram
How to tell your system which Java version to use is explained here:
Why does java -version returns old version?
JRE [java command] come with your JDK 1.7, and you must change your JAVA_HOME variable to your JDK 1.7 folder.for this work read this article

Resources