File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Setting up Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Setting up Java" Watch "Setting up Java" New topic
Author

Setting up Java

Carlos Montes
Greenhorn

Joined: Aug 02, 2003
Posts: 7
I downloaded and installed the j2sdk-1_4_1_02-s1studio_ce-4u1-bin-windows pack.
Java webstart is here C:\ProgramFiles\Java Web Start
The j2re1.4.0 is here C:\ProgramFiles\Java Web Start\j2re1.4.0
The j2re1.4.1_02 file is located in:
C:\ProgramFiles\Java Web Start\j2re1.4.1_02
I created a folder where I want to store my "projects" in this directory:
C:\Documents and Settings\shr3dd3r\My Documents\javastuff
When I try to compile this code:

I get this error.

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\shr3dd3r>cd my documents\javastuff
C:\Documents and Settings\shr3dd3r\My Documents\javastuff>javac practice.java
'javac' is not recognized as an internal or external command,
operable program or batch file.

What am I doing wrong?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

I"m not quite sure what "j2sdk-1_4_1_02-s1studio_ce-4u1-bin-windows" is (long, unfamiliar filename) but basically, to compile Java programs you ought to have a program named javac.exe that was installed as part of this bundle. If you do, then the problem is just that the directory it's in needs to be on your PATH. If you don't, then you didn't download the right thing. You just want the J2SDK from java.sun.com.


[Jess in Action][AskingGoodQuestions]
Carlos Montes
Greenhorn

Joined: Aug 02, 2003
Posts: 7
http://java.sun.com/j2se/1.4.1/download.html
This one right?
[ August 04, 2003: Message edited by: Carlos Montes ]
Karthikeyan Rajendraprasad
Ranch Hand

Joined: Apr 16, 2003
Posts: 70
the error is because the javac is not in the path.
set the path as
set path=%path%;C:\jdk1.4\bin;
you search for the javac.exe and set the path as said above. for me it is in C:\jdk1.4\bin; so i am setting it as said above.you put your java path accordingly


Karthikeyan<br />SCJP 1.4, SCWCD.
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
You post a link that has all kinds of downloads and ask if it's the right one? Well... yes... some of those are the 'right' one. You want the JDK for development, based upon the filename you provided I'm guessing you download the Sun ONE Studio 4 Community Edition IDE bundled with the 1.4.1 SDK. So you SHOULD have the SDK installed somewhere, you just need to find it and set your path accordingly.
And... if you're going to download the IDE why would you be compiling from the command prompt? Also... why not 1.4.2?
Paul Knox
Greenhorn

Joined: Aug 05, 2003
Posts: 2
Hi Carlos,
What you need to get up and running is the following.
Download the Windows (all languages, including English) from the URL you gave. Download the SDK and not the JRE. The SDK is the Software Development Kit which contains the Java compiler (javac.exe).
Install this on your machine.
Then depending on your operating system you need to set a system environment variable to the following
set PATH=%PATH%;c:\[your java install directory]\bin
If you look in this directory eg c:\[your java install directory]\bin you will see the javac.exe compiler, you must set the path environment variable to this directory.
Finally all you would have to do is compile your file as follows
javac myprog.java
this will generate your class file
myprog.class
to run this simply type
java myprog
hope this helps
Carlos Montes
Greenhorn

Joined: Aug 02, 2003
Posts: 7
Originally posted by Paul Knox:

Then depending on your operating system you need to set a system environment variable to the following
set PATH=%PATH%;c:\[your java install directory]\bin
If you look in this directory eg c:\[your java install directory]\bin you will see the javac.exe compiler, you must set the path environment variable to this directory.

I don't get this? My install Directory?
Ive downloaded all that stuff you told me to and it is as follows:
C:\j2sdk1.4.2
The Javac.exe compiler is here C:\j2sdk1.4.2\bin
My javastuff folder is here:
C:\Documents and Settings\shr3dd3r\My Documents\javastuff
the first file that ive coded has this path:
C:\Documents and Settings\shr3dd3r\My Documents\javastuff\practice.java
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
Originally posted by Carlos Montes:
The Javac.exe compiler is here C:\j2sdk1.4.2\bin
My javastuff folder is here:
C:\Documents and Settings\shr3dd3r\My Documents\javastuff
the first file that ive coded has this path:
C:\Documents and Settings\shr3dd3r\My Documents\javastuff\practice.java

You need to be sure that C:\j2sdk1.4.2\bin is in your PATH.
You need to be sure that C:\Documents and Settings\shr3dd3r\My Documents\javastuff\ is in your CLASSPATH.

Then you can type javac practice.java while you are in the C:\Documents and Settings\shr3dd3r\My Documents\javastuff\ directory. That will put your practice.class in the same subdirectory.

Now you can type java practice to see the result of your program.
[ August 05, 2003: Message edited by: Marilyn de Queiroz ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Karthikeyan Rajendraprasad
Ranch Hand

Joined: Apr 16, 2003
Posts: 70
Originally posted by Carlos Montes:

I don't get this? My install Directory?
Ive downloaded all that stuff you told me to and it is as follows:
C:\j2sdk1.4.2
The Javac.exe compiler is here C:\j2sdk1.4.2\bin
My javastuff folder is here:
C:\Documents and Settings\shr3dd3r\My Documents\javastuff
the first file that ive coded has this path:
C:\Documents and Settings\shr3dd3r\My Documents\javastuff\practice.java

type the following in your prompt
set path=%path%;C:\j2sdk1.4.2\bin;
set classpath=%classpath%;.;
it will be like
C:\Documents and Settings\shr3dd3r\My Documents\javastuff>set path=%path%;C:\j2sdk1.4.2\bin;
C:\Documents and Settings\shr3dd3r\My Documents\javastuff>set classpath=%classpath%;.;
C:\Documents and Settings\shr3dd3r\My Documents\javastuff>javac practice.java
C:\Documents and Settings\shr3dd3r\My Documents\javastuff>java practice
now you can compile and run your code

[ August 05, 2003: Message edited by: Karthikeyan Rajendraprasad ]
Carlos Montes
Greenhorn

Joined: Aug 02, 2003
Posts: 7
Originally posted by Karthikeyan Rajendraprasad:

type the following in your prompt
set path=%path%;C:\j2sdk1.4.2\bin;
set classpath=%classpath%;.;
it will be like
C:\Documents and Settings\shr3dd3r\My Documents\javastuff>set path=%path%;C:\j2sdk1.4.2\bin;
C:\Documents and Settings\shr3dd3r\My Documents\javastuff>set classpath=%classpath%;.;
C:\Documents and Settings\shr3dd3r\My Documents\javastuff>javac practice.java
C:\Documents and Settings\shr3dd3r\My Documents\javastuff>java practice
now you can compile and run your code

[ August 05, 2003: Message edited by: Karthikeyan Rajendraprasad ]

TY it works now.
But do I have to set the path every time I do this? How do i permanently set the path?
[ August 05, 2003: Message edited by: Carlos Montes ]
Karthikeyan Rajendraprasad
Ranch Hand

Joined: Apr 16, 2003
Posts: 70
there are two option
1. set it in the system
2. create a batch file and run it whenever necessary
set it in the system
windows 95/98
add the two lines in the autoexec.bat
set it in the system
windows NT/2000
right click my computer select properties in that select advanced tab and in that environment variables you have two options here. add for current user or all users[system] select new and add the two lines one by one

create a batch file and run it whenever necessary
open Notepad paste those lines and save it as a batch file say paths.bat run this batch file when ever you go to command prompt instead of typing those two lines.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting up Java
 
Similar Threads
Setting up Paths Permanently
absolute newbie compile error
Mouse shift event coding - to trigger a predetermined sequence of images to a GUI
Run applet from command line
Program: Change Due/Tendered