You are on page 1of 4

First of all there is no Vista Service pack 2.

Secondly, assuming that you installed Java JDK, now you need to setup the environment
variables.

1. Click Start button, type Accounts in the Start search box, and then click User Accounts
under Programs.User Account Control permission If you are prompted for an administrator
password or for a confirmation, type the password, or click Allow.

2. In the User Accounts dialog box, click Change my environment variables under Tasks.

3. Now in the User Variables, Click on New. In the Variable Name field type “Path” and in
the Variable Value field type the path to the JDK, most probably under default installation it
should be “C:\Program Files\Java\jdk1.6.0_06\bin;”

4. Open a Notepad, create a java program and save it as *classname*.java, Now open a
command prompt and navigate to the folder where the java file is saved. Now type “javac
*classname*.java” to compile the code. To execute the program type “java *classname*”

That’s all you needed to do.

sample program: filename- hello.java

public class hello


{
public static void main(String[] args)
{
System.out.println(”Hello, World!”);
}
}

Hi, What I Ultimately want to do is set my command line up so i can compile a java file from
any directory.

I have downloaded jdk and jre and I set the Path in environmental variables to where my jdk
bin is located which is, ;C:\Program Files\Java\jdk1.6.0\bin

When I am in the command line and have the directory in the bin folder, the Javac command
works fine

When I am in a different folder and use javac, it gives me an error that says " 'javac' is not
recognized as an internal or external command, operable program or batch file. "

I'm wondering how I am able to compile a java file from some other directory such as my
documents. I know it can be done becuase i've done it before on my other computer, but that
computer had vista and I forgot how to do it altogether. Thank you.
brad211987
03-27-2009, 03:36 AM
On the windows command line, enter the command "set" without quotes. Copy the results
back up here so I can see your environment variables setup in the context of your command
session.
bdl
03-27-2009, 03:41 AM
You mention you've setup the PATH to include the 'bin' directory. If that's the case, then you
should have no trouble accessing the javac or java executables from anywhere in the
directory structure.

At the command line, issue this command: echo %PATH%, and make sure the Java 'bin'
directory is included as you expect.

A couple of tips to setting up Windows properly for JDK:

Install the JDK to C:\Java\jdk-version. Avoid any path that includes a space, such as the
default C:\Program Files\Java\jdk-version.
Afterwards, create a couple of useful directories, such as C:\Java\JAR and
C:\Java\workspace. The JAR directory can be an archive for any jar library files that you use
in your applications, or your own custom archives. The 'workspace' directory should be self-
explanatory. ;)
Create an environmental variable named "JAVA_HOME" that points to C:\Java\jdk-version
directory.
Create an environmental variable named "CLASSPATH" that includes the current working
directory, and the aforementioned optional JAR directory, e.g. .;C:\Java\JAR\* (note that Java
v6+ allows the use of wildcards for directories that include jar files)
Append the PATH variable with %JAVA_HOME%\bin, since the JAVA_HOME variable
has already been set
servlet
03-27-2009, 07:32 AM
Look at http://www.jsptube.com/servlet-tutorials/setup-servlet-development-
environment.html.

Refer to installing java SDK section.


coderguy112233
03-28-2009, 01:40 AM
You mention you've setup the PATH to include the 'bin' directory. If that's the case, then you
should have no trouble accessing the javac or java executables from anywhere in the
directory structure.

At the command line, issue this command: echo %PATH%, and make sure the Java 'bin'
directory is included as you expect.

A couple of tips to setting up Windows properly for JDK:

Install the JDK to C:\Java\jdk-version. Avoid any path that includes a space, such as the
default C:\Program Files\Java\jdk-version.
Afterwards, create a couple of useful directories, such as C:\Java\JAR and
C:\Java\workspace. The JAR directory can be an archive for any jar library files that you use
in your applications, or your own custom archives. The 'workspace' directory should be self-
explanatory. ;)
Create an environmental variable named "JAVA_HOME" that points to C:\Java\jdk-version
directory.
Create an environmental variable named "CLASSPATH" that includes the current working
directory, and the aforementioned optional JAR directory, e.g. .;C:\Java\JAR\* (note that Java
v6+ allows the use of wildcards for directories that include jar files)
Append the PATH variable with %JAVA_HOME%\bin, since the JAVA_HOME variable
has already been set

From what you said before about me being able to access the javac command because i have
set a directory to the bin folder.
I am able to use the javac command only if that file is in the folder Bin, but If I have the java
file in documents and set the command line so it is in the documents folder, then it says i can
not access the javac command.
I would like to be able to use the javac command from anywhere. Thanks.
brad211987
03-28-2009, 01:42 AM
Do what I said above so we can see that your environment is configured properly.
coderguy112233
03-28-2009, 01:43 AM
is there anyway to copy that because its a really long paragraph of stuff
brad211987
03-28-2009, 01:45 AM
Click on the icon at the top left of the command window and select "mark" then highlight
everything and go back to the same place and click "copy"
coderguy112233
03-28-2009, 01:59 AM
C:\Users\Brady>set
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Brady\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=HPMOBILE
ComSpec=C:\Windows\system32\cmd.exe
EMC_AUTOPLAY=C:\Program Files\Common Files\Roxio Shared\
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\Brady
LOCALAPPDATA=C:\Users\Brady\AppData\Local
LOGONSERVER=\\HPMOBILE
NUMBER_OF_PROCESSORS=1
OS=Windows_NT
Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program
Files\Co
mmon Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\DL
LShared\;C:\Program Files\Common Files\Roxio Shared\11.0\DLLShared\;C:\Program F
iles\Java\jdk1.6.0\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 13 Stepping 8, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0d08
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
PROMPT=$P$G
PUBLIC=C:\Users\Public
RCAUTOPLAY=C:\Program Files\Roxio Creator 2009\Roxio Central 4\
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\Brady\AppData\Local\Temp
TMP=C:\Users\Brady\AppData\Local\Temp
USERDOMAIN=HPMobile
USERNAME=Brady
USERPROFILE=C:\Users\Brady
windir=C:\Windows
coderguy112233
03-28-2009, 03:23 AM
did that help you, please reply and help me fix my question it is really frusterating
bdl
03-28-2009, 04:13 AM
Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program
Files\Co
mmon Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\DL
LShared\;C:\Program Files\Common Files\Roxio Shared\11.0\DLLShared\;C:\Program F
iles\Java\jdk1.6.0\bin

Provided that you installed the JDK to C:\Program Files\Java\jdk1.6.0, and there is a
subdirectory named 'bin', you should be all set. The fact that you still cannot access the 'javac'
executable from any directory path in the command line is strange. Vista may require some
magic that I'm not aware of, although I did have Java working on my Vista laptop before I
wiped the drive and installed Slackware, and I can't think of anything different I had to do.

You might also like