I installed JDK on my PC running windows XP, the default directory of JDK is :
C:\Program Files\Java\jdk1.7.0_05\bin
I'm following the tutorial to do a sample
My source file named HelloWorld is in another directory : E:\NotePad\Code
As the tutorial says : "To compile your source file, change your current directory to the directory where your file is located" , so I change my Command's current directory to E:\NotePad\Code , but here comes the problem which is saying 'javac' is not recognized as an internal or external command
Well, the tutorial has a solution to this problem, it seems that I should change Command Line's current directory to where the JDK is installed which is : C:\Program Files\Java\jdk1.7.0_05\bin
After I finish it, I try this commond : javac HelloWorld.java to compile the file, but it says
javac : cannot find file : HelloWorld.java
It means that the HelloWorld.java file in E:\NotePad\Code can't be compiled by the JDK which is installed in C:\Program Files\Java\jdk1.7.0_05\bin
I try putting the HelloWorld.java file in C:\Program Files\Java\jdk1.7.0_05\bin , it works fine
So the question is : How can I Compile&Run a file with the JDK installed in a different directory ?
You will either need C:\Program Files\Java\jdk1.7.0_05\bin on your PATH, or reference the compiler directly using
C:\Program Files\Java\jdk1.7.0_05\bin\javac
It sounds like you need to update your PATH variable, see here: http://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-windows.html#path
Related
I have the latest STS4. I am using installed java-1.8 JDK not embedded as the execution environment. My project just runs fine without any issue.
However when I launch the STS application itself I have a pop up saying
"Missing tools.jar"
I have already tried:
pointing JAVA_HOME to different JDK
added -vm args in the .ini file.
Yet I cannot get rid of this pop up.
I solved this same problem by modifying the file "eclipse.ini". First I tried to solve it by modifying the file SpringToolSuite4.ini, but nothing happened, because I previusly had installed the eclipse ide, and the change in SpringToolSuite4.ini didn't work. then I modified the file eclipse.ini; and it worked.
The changes that I did in eclipse.ini are detailed below:
To check with what Java version (JRE or JDK) Eclipse is running, do the following:
Open the menu item Help > About Eclipse. (On the Mac, it’s in the Eclipse-menu, not the Help-menu)
Click on Installation Details.
Switch to the tab Configuration
Search for a line that starts with -vm. The line following it shows which Java binary is used.
Depending on the name and location of the used Java binary one can figure out if a JRE or a JDK is used:
If the path contains “jre” (e.g. as in C:\Program Files\Java\jre6\bin\client\jvm.dll) it is a JRE
If the path contains “jdk” (e.g. as in C:\Program Files\Java\jdk1.6.0_31\bin\javaw.exe) it is a JDK.
If no JDK is used for Eclipse, change it:
Quit Eclipse if it is running
Go to the Eclipse installation directory and open the file eclipse.ini in a text editor.
Search for the line -vmargs
Before the line -vmargs, add two lines:
On the first line, write -vm
On the second line, write the path to your JDK installation (usually something like: C:\Program Files\Java\jdk1.6.0_31\bin\javaw.exe on Windows)*
source: https://matsim.org/docs/devguide/eclipse/jdk
The fix is in the -vm parameter. the order and the absolute path of the javaw.exe seems to be the issue.
the readme file mentions _
"To run Eclipse with an alternate Java runtime environment, the path to the Java virtual machine's binary must be identified. With an Eclipse installation from the distribution, altering the $PATH variable to include the path to the alternate Java runtime environment is often not enough as the Eclipse that Linux distributions package often performs a scan internally to pick up GCJ by itself whilst ignoring what's on the $PATH."
So I have edited now the SpringToolSuite4.ini and made this entry
-vm
C:\UserTemp\Softwares\java\jdk\oracle-jdk-1.8-64bit\bin\javaw.exe
Restarted my STS and it works perfect.
The reference to set the JVM Specifying the JVM was very useful in understanding this.
Don't spend too much time looking for tools.jar. If you get an error like that, don't be upset.
If you already have java JDK1.8, go to its lib folder, tools.jar should be available there. Copy and paste the same in JRE1.8 lib folder.
I have STS4 so I have modified SpringToolSuite4.ini
I changed from:
[...]
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.8
[...]
to exactly this
[...]
--launcher.defaultAction
openFile
-vm
C:\Program Files\Java\jdk1.8.0_152\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.8
[...]
And the message dissapeared
SOLUTION :
Check your Path JAVA_HOME - system property "Environment Variables"
for example: JAVA_HOME:
C:\Program Files\Java\jdk-12.0.1\lib
usually you only need add \lib at JAVA_HOME
Just remove this line from variable "Path"
"C:\Program Files (x86)\Common Files\Oracle\Java\javapath"
System Properties > Advanced > Environment Variables > Path > Edit > Reboot
Worked for me
In my case I had installed jre, and not jdk!
Observe that you have jdk installed!
I had the same issue when i upgraded to Java 11.
I simply edited SpringToolSuite4.ini and added
-vm
C:\Program Files\Java\jdk-11.0.4\bin\javaw.exe
For me, I had to do two things to make it work:
Remove vmargs:
vmargs
Dosgi.requiredJavaVersion=1.8
Setting the JDK:
vm
C:\Program Files\Java\jdk1.8.0_131\bin
By downloading the tool file and paste it in the jre\lib path. but make sure you should rename the pasted file as "tools.jar".
step 1
download the tool file.
download link http://www.java2s.com/Code/Jar/t/Downloadtools160jar.htm
step 2
extract the zip file.
step 3
you should rename the included .jar file as "tools".
step 4
then copy the renamed tools.jar file and paste in the C:\Program Files\Java\jre8\lib\ path.
then restart the STS ide.
I have fixed this from Window->preferences->Java->Installed JREs .
Then add the jdk bin path, uncheck other related jre paths
Copy JDK directory to your STS installation or extraction library and and rename JDK to jre. the directory structure of STS should look like this
.eclipseproduct
artifacts.xml
configuration
dropins
eclipsec.exe
features
jre
license.txt
META-INF
open-source-licenses.txt
p2
plugins
readme
SpringToolSuite4.exe
SpringToolSuite4.ini
Once STS open, initially its looking for tools.jar in jre\lib folder its not available in jre\lib folder.
so we need copy the tools.jar from jdk\lib folder and paste in jre\lib folder.
restart the STS, issue will resolve.
Error:java: Cannot run program "C:/Program Files/Java/jdk1.7.0_45/bin/java" (in directory "C:\Users\navya.chamidisetty\.IntelliJIdea2017.3\system\compile-server"):
CreateProcess error=2,
The system cannot find the file specified
I have started using IntelliJ 17 recently. When I checkout all my code in a folder and C:\ and loaded in Intellij. Now when I try to build, I am getting the above mentioned error. Could someone please help me how to solve this.
My %JAVA_HOME% = C:\Program Files\Java\jdk1.8.0_151
Value of Path variable in Environment variables = C:\Program Files\Apache Software Foundation\apache-maven-3.0.3\bin;C:\newcorpweb\cxf\bin
Value of Path variable in System variable = C:\Program Files\Java\jdk1.8.0_151\
IDEA doesn't necessary use JAVA_HOME variable. The project SDK (JDK in your case) is setup in the project settings: File -> Project Structure, Project SDK and set up the proper path there.
I have the same issue on NixOS with IntelliJ 2020.2. If I choose evident File -> Project structure -> SDKs -> + -> Download JDK, Idea does not see this downloaded JDK (error=2 etc.). But if I install and choose a system openjdk (located at /nix-store/...-openjdk-.../), everything works.
Using Open JDK by Red Hat solved my problem!
Link for the JDK
Open JDK by Red Hat
I just install Codename plugin in Intellij and just about to start learning the tool. Have the following error message upon creating a new codename project in Intellij:
Error opening resource editor: Cannot run program "C:\Program Files (x86)\Android\android-sdk\bin\java.exe" (in directory "C:\Program Files (x86)\Android\android-sdk\bin"): CreateProcess error=267, The directory name is invalid
java.io.IOException: Cannot run program "C:\Program Files (x86)\Android\android-sdk\bin\java.exe" (in directory "C:\Program Files (x86)\Android\android-sdk\bin"): CreateProcess error=267, The directory name is invalid
The plugin should not look for java.exe inside android-sdk folder. I have set the JAVA_HOME environment variable to the proper JDK path. This only happen in Codename plug-in.
Been searching SO for answer, but to no avail. Looking to tweak around the plugin way of finding java.exe.
OS: Windows 10, Intellij version: 2016.1.1
Are you using the 3.3 or higher version of the plugin?
Notice that Android studio isn't a supported platform only IntelliJ IDEA itself.
I'd like to know more about how you were able to create that state but the fix should be simple:
Right click the project and select "Open Module Settings"
Make sure the SDK selected is a Java SDK, JDK 8 is assumed
Had hoped that this would help, but getting a different error.
attempting to compile the following as hello.cs
using Gtk;
using System;
class Hello
{
static void Main()
{
Application.Init();
Window window = new Window("helloworld");
window.Show();
Application.Run();
}
}
Compiling with the following command "gmcs hello.cs -pkg:gtk-sharp-2.0"
depending on the command prompt, I'm receiving either cs0006 (mono cp) or cs2001 (win cp) saying that files cannot be found
from mono cp it says that the metadata file cannot be found
from win cp it says that source file cannot be found
Here's a sample:
c:\Users\Stephen Lloyd\Desktop>gmcs hello.cs -pkg:gtk-sharp-2.0
-r:C:/Program Files \(x86\)/Mono-2.10.8/lib/mono/gtk-sharp-2.0/pango-sharp.dll \(x86\)/Mono-2.10.8/lib/mono/gtk-sharp-2.0/atk-sharp.dll \(x86\)/Mono-2.10.8/lib/mono/gtk-sharp-2.0/gdk-sharp.dll \(x86\)/Mono-2.10.8/lib/mono/gtk-sharp-2.0/gtk-sharp.dll \(x86\)/Mono-2.10.8/lib/mono/gtk-sharp-2.0/glib-sharp.dll
error CS2001: Source file `Files' could not be found
error CS2001: Source file `\(x86\)/Mono-2.10.8/lib/mono/gtk-sharp-2.0/pango-sharp.dll' could not be found
error CS2001: Source file `\(x86\)/Mono-2.10.8/lib/mono/gtk-sharp-2.0/atk-sharp.dll' could not be found
error CS2001: Source file `\(x86\)/Mono-2.10.8/lib/mono/gtk-sharp-2.0/gdk-sharp.dll' could not be found
error CS2001: Source file `\(x86\)/Mono-2.10.8/lib/mono/gtk-sharp-2.0/gtk-sharp.dll' could not be found
error CS2001: Source file `\(x86\)/Mono-2.10.8/lib/mono/gtk-sharp-2.0/glib-sharp.dll' could not be found
Compilation failed: 6 error(s), 0 warnings
In all cases the referenced .dlls are in that folder.
Any thoughts?
-pkg is broken on Windows; you will need to supply individual individual -r[eference]:s. Please see this answer for details.
As an alternative to manually entering references, I found it easier to just install mono to a path with no spaces aka C:\devtools\mono and then adding the ... C:\devtools\mono\bin to your path. The command was then successful for me. As an aside I have had a similar problem before with using unix devtools on windows and this has worked there as well.
Had this problem on MacOSX. The solution to add the mono bin directory to path solved it for me.
Specifically,
"/Library/Frameworks/Mono.framework/Versions/Current/bin"
needed to be on my path.
I did this:
export MONOPATH=/Library/Frameworks/Mono.framework/Versions/Current
export PATH=${PATH}:${MONOPATH}/bin
And afterwards, I was able to compile via:
gmcs /t:exe /debug+ -pkg:dotnet WinFormsHello.cs
(likewise for gtk# etc)
I was having the same problem running this on Windows 10. Since Windows supports symbolic links, since Vista, I thought this might be a solution ... it worked for me.
As Administrator, I created a directory symbolic link from the root directory to mono:
cd \
mklink /d mono "\program files x(86)\mono"
Then, again as Administrator, I edited the "Open Mono Command Prompt" shortcut properties:
Target: C:\Windows\SysWOW64\cmd.exe /k "C:\Mono\\bin\setmonopath.bat"
Start In: C:\Mono
Now when pkg-config parses the drive-path of mono.exe it "sees" only c:\mono and will proceed to append the rest of the path to resolve the required packages.
You can set your symbolic link from any directory. I set it from root for sake of simplicity. The main purpose is to establish a path without spaces or special characters.
i install JDK in
C:\Program Files\Java\jdk1.6.0_24
and set the variables as follow:
JAVA_HOME: C:\Program Files\Java\jdk1.6.0_24
CLASSPATH: .;C:\Program Files\Java\jdk1.6.0_24\lib;C:\Program
Files\Java\jdk1.6.0_24\lib\tools.jar;
PATH: C:\Program Files\Java\jdk1.6.0_24\bin
but when i run the java -version command , the error
could not open `C:\Program Files\Java\jre6\lib\i386\jvm.cfg'
comes up. then i move the jre folder out the jdk folder to
C:\Program Files\Java\
and change the folder name to jre6 (then it has the C:\Program Files\Java\jre6 folder) , everything becomes good then .
why this is happening ? it seems to me that it is not the environment variables that are controlling the JVM's location.
If it is not the path that is controlling the location of the JRE it must be the registry:
http://java.sun.com/j2se/1.3/runtime_win32.html.
On Windows 64 bit OS check also:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment
I set my
JAVA_HOME: C:\Program Files\Java\jdk-14.0.2
worked fine for me.