Problem to access java.exe - windows

Hy!!
My Problem is that my terminal doesn't know the command java.
So i will solve the problem to access the java.exe directly.
Code:
'C:\Program Files\Java\jre6\bin\java.exe' -blabla
Exception:
Wrong Syntax
Please help

For your terminal to recognize command java you must put the entry C:\Program Files\Java\jre6\bin\ in your Environmental Variables in the variable called PATH.
To do so on Windows:
Right mouse click on "My Computer" and select "properties"
Go to Advanced tab
In "Advanced" click on button "Environmental Variables"
In "System Variables" edit PATH entry adding ; to the last entry
Save and restart terminal
EDIT: To run it like you want you should use " instead of '. So your command will look like:
"C:\Program Files\Java\jre6\bin\java.exe" -version

You probably need to add the path to the installed JAVA code to your enviroment PATH variable. This will allow you to just type java.exe at the command line and have it find the executable without needing the full path. Then you could type java -help to see the options available.

Related

How to append to the PATH variable in Visual studio 2013

I want to append a value to my PATH environment variable. I thought this should be easy but its not working in the Developer Command Prompt for VS2013. I have tried the following commands:
set PATH = C:\temp;%PATH% //No quotes
set "PATH = C:\temp;%PATH%" //Quotes around everything
set PATH = "C:\temp;%PATH%" //Quotes only around the value
set PATH = "C:\temp;"%PATH% //Quotes around the new value to be appended
I have looked online and everyone seems to suggest the first or the second option above but when I
echo %PATH%
I dont see C:\temp in the PATH variable.
Any help is appreciated. I am on windows 7 and I work in python but needed to install quantslib. So, I have to go through visual studio.
The environment block is captured when a process starts, which means that Visual Studio won't see the updated path unless you restart it.
Editing the path from the command prompt is possible, but this is the easier way to modify an environment variable:
Right Click on "My Computer"
Click on "Properties"
In the Left-Hand Column, Select "Advanced system settings"
Click on the "Environment Variables..." button.
Under "System variables" select the "Path" variable, then click "Edit...".
Edit the path to your heart's content, then click "OK"
Press "OK" on the two open dialogs. If any program that's currently running needs this path, you'll have to restart that program. If you want to be really sure that everyone has the new PATH values, reboot the computer.

windows7 class path changed

I write java in command line, But Output is here:
But my jdk is here:
D:\Windows.old\Program Files\Java\jdk1.7.0_11
What should do?
Can i set windows java class path to D:\Windows.old\Program Files\Java\jdk1.7.0_11 Or not?
My windows is is C drive.
yes, you must set java class path to D:\Windows.old\Program Files\Java\jdk1.7.0_11
Otherwise Environment variable does not find jdk1.7
Step how to set Class Path Window 7
Open Control Panel and Select System and Security
Select System
Select Advanced System Settings (Left Side)
Pop up Window Select "Advanced" (Tab)
Select Environment Variables (bottom)
Select and Edit Path Environment variable (add with this ;D:\Windows.old\Program Files\Java\jdk1.7.0_11) Do not delete the path existent,
Verify Java path by typing javac in command prompt
javac is not recognize:
Go to Control Panel. Environment Variables and Insert the address at the beginning of var. Path followed by semicolon. i.e D:\Windows.old\Program Files\Java\jdk1.7.0_11; . Do not delete the path existent, just click in and go to the left end and paste the line above. Do not try anything else, because you just need to link your code to "javac.exe" and you just need to locate it.
Try to execute
Close your command prompt and reopen it,and write the code for compile and execution.

javac is not working even after setting the path in windows xp

Friends I couldn't access java in my xp even after i set the path
i set the path as set path="C:\Program Files\Java\jdk1.7.0_25\bin"
It doesn't work in xp But it is useful in my windows 7 System
Don't know why
Please answer me
I also set path variable in the environment variables tab.But that doesn't worked for me
Still my javac command says javac is not recognised external or internal command.
So please help me
Run this command in Command Prompt/CMD
set path="%path%;c:\program files\java\jdk1.7.0_25\bin"
If you already have a instance of terminal opened, you'll have to close it and re-open for work. Make sure this path C:\Program Files\Java\jdk1.7.0_25\bin is valid and has javac.
1>First check if java is really installed in your PC.
You can do this by going to
C drive->Program Files->Java
Inside java you should have two folders
1. jdk
2.jre
2> copy the path C:\Program Files\Java\jdk1.7.0_25\bin
(jdk1.7.0_25 is the jdk version you have installed as you mentioned)
3>Go to advanced system settings and click on Environment variables
4>Click on new and you will have two fill the variable name and variable value.
type in " PATH " (without the double quotes and in CAPS) in the variable name
and paste the copied path in the variable name field.
5>Now open a new command prompt and type javac.
You should see a list and not the error you mentioned.
Another way..but this way is only a temporary solution since once you close cmd you will have to set path again.
You can even set path= (paste the path you copied after the equals sign)
First follow these steps
Start -> Control Panel -> System -> Advanced
Click on Environment Variables, under System Variables, find PATH, and click on it.
In the Edit windows, modify PATH by adding the location of the class to the value for PATH.
If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
Close the window.
Reopen Command prompt window, and run your java code.
now Run where java. this should return java path up to java.exe
If still you are having issues leave a comment

Adding a Application specific paths, so it works from the command line in Windows

Following the guide from Microsoft,
http://msdn.microsoft.com/en-us/library/ee872121(VS.85).aspx , I am able to get my program to be able to make a program resolve the dynamic libraries that are required in order for it to work.
So I add a value with the full name and path to my executable, and add subkey to this entry (named path) with the full path the directory of the DLL files.
And magic. It works. I go the start menu, and types myprogram.exe and it starts up and is now able to locate the dll files correctly.
However, if I start the command prompt using the command cmd.exe, and then try to run myprogram.exe is not able to resolve the DLL's anymore. For some reason the command prompt do not seems to respect/read the values of the registry when it is set under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
Any suggestion to how I can get this behavior to work from within the command prompt as well as from the start menu?
It is correct. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths is used by ShellExecuteEx and not by CreateProcess. So not all programs will use the settings from App Paths of your application. If you want to define PATH for cmd.exe you can either use subkey of App Paths with the name cmd.exe or use an old %SystemRoot%\System32\autoexec.nt file to modify PATH environment variable.
It's also possible to use "START /WAIT app.exe" from command line which uses ShellExecuteEx.
I'll give it my best shot.
First, notice that both the cmd & the run\start menu options are running everything in C:\WINDOWS\system32.
If you're dll was there then it would work.
if you don't want to put it there, you can change the "environmental variables" by clicking right mouse button on "my computer"-> "properties" -> "Advanced" -> "environmental variables".
good luck.

How to write a script/batch file on windows?

I am using a machine where I do not have administrator privileges and I need to set the e.g. JAVA_HOME each time I boot.
Thus, I'd like to write a script that sets the desired classpath automatically.
How do I do this?
You surely can set the environment variables with a batch file each time you need them, but bear in mind that this will only work for the current process (i. e. the cmd instance you're invoking the batch from) and processes spawned from there. I think you'd rather want persistent environment variables.
Now, in the UNIX world you'd just put them into your shell startup script. In Windows ... not exactly that way.
Right click on "My Computer", select "Properties".
There, go to the "Advanced" tab
Click the button labeled "Environment variables"
You can set JAVA_HOME and GRAILS_HOME under "User variables" there.
You would only need administrator access for changing the system environment variables.
You would want a file with .bat extension for Windows.
SET JAVA_HOME=path
SET GRAILS_HOME=path
On Windows, you could write a .BAT file (BATch), and then simply double-click it each time you log in. a .BAT file is simply a plain text file filled with any commands you would normally issue at the command prompt, e.g.:
cd c:\Temp
c:
set PATH=%PATH%;c:\Program Files\Some Directory\Some Subdirectory
You can optionally precede each line with the # symbol to stop it being echoed to the command window when it executes.
Try calling the following :
SETX JAVA_HOME path
SETX GRAILS_HOME path
If you're allowed they will be set in your profile and you won't need to run them again hopefully. Other wise you'll need to follow #Android's answer

Resources