question about JAVA compiling ..


 
Thread Tools Search this Thread
Operating Systems Solaris question about JAVA compiling ..
# 1  
Old 08-08-2005
question about JAVA compiling ..

Hi ,
I don't know if this is the right place to post my question because it relates to JAVA . I am beginner of JAVA , using a tutorial as reference I am trying to run a simple program in JAVA env. I have installed JDSK kit from java.sun.com but when I tried to run a program from the DOS prompt , I am getting this error ,
This what I typed in : C:/Documents and Setting\javac -classpath ExampleProgram.java
Error I got :
'javac' is not recognized as an internal or external command.


I tried to set the environment variable also, but it is not working.

Please help.

Thanks.
# 2  
Old 08-08-2005
What env variables have you set ?

JAVA_HOME/bin directory should be in your path. JAVA_HOME is where you
have installed the java sdk.

Also, if you set the env variables, you need to open another command prompt window and then try your command, again.

vino
# 3  
Old 08-08-2005
question about JAVA compiling..

Thanks Vino.

I have installed jdk in c:/Program Files directory. Won't I be able to use from this location.
If you don't mind could u walk me through the steps after installation .


thanks
# 4  
Old 08-09-2005
If c:\Program Files\j2sdk1.5 is where you have installed java sdk.

You can run javac from this directory as well. But getting a command prompt to traverse to this directory requires you to type in extra. So put c:\Program Files\j2sdk1.5\bin in your path. After that you can run javac, java from anywhere.

It is best that you set classpath to include the current directory. Just append a . to the CLASSPATH settings if not already set.

javac ExampleProgram.java

Look at this instruction manual

vino
# 5  
Old 08-10-2005
Hi Vino,
Thanks for your time.

But still I am getting error saying "cannot read:ExampleProgram.java"

These are all the steps I tried .

1. I made C:/Program Files\Java\jdk1.5.0_04\bin (this were I have installed jdk) as my current working directory.
2 . then I setted up my CLASSPATH -->
C:/Program Files\Java\jdk1.5.0_04\bin > SET CLASSPATH=%CLASSPATH%;.

3. then I complied my program from the above location :

C:/Program Files\Java\jdk1.5.0_04\bin >javac ExampleProgram.java
At this stage I am getting this error .
error : "cannot read:ExampleProgram.java" 1 error

Here is what the code I wrote :
class ExampleProgram {
public static void main(String[] args){
System.out.println("I'm a Simple Program");
}
}

Could you tell me what I am missing here? I appreciate your patience and time vino.


Thanks.
# 6  
Old 08-10-2005
Where did you place the ExampleProgram.java? Right inside jdkXXXXX\bin?? You shouldn't put any user programs inside!
# 7  
Old 08-11-2005
I will start again.

You should add the following to your path variables.
C:/Program Files/Java/jdk1.5.0_04/bin

You will need the classpath setting SET CLASSPATH=%CLASSPATH%;.

Suppose, all your java programs are placed in c:/ANAMIKA56

You will need to traverse to c:/ANAMIKA56 and then issue javac ExampleProgram.java

Once the program is compiled, run it as follows: java ExampleProgram

The path settings is necessary because after that, you go to any directory you want and then issue a javac/java. If you dont set the path variable, you need to do the following everytime. C:/Program Files/Java/jdk1.5.0_04/bin/javac ExampleProgram.java.

Like cbkihong said, its good not to put any java programs inside the java installation directory.

vino
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compiling and Executing a Java File With a Shell Script

I'm trying to use a shell script to compile and execute a java file. The java classes are using sockets, so there is a client.java file and a server.java file, each with their own shell script. I also want to handle the command line arguments within the shell script, not the java classes. The... (1 Reply)
Discussion started by: britty4
1 Replies

2. Shell Programming and Scripting

Compiling all modified Java files in a folder on Unix

Hi all, I have a Unix script that will compile all Java files in a sub folder as follows: find . -name "*.java" -print -exec $JAVA_HOME/bin/javac -cp .:$CLASSPATH '{}' \; I would like to enhance it to only compile those Java files who: 1.) Have no class file 2.) Have a class file... (1 Reply)
Discussion started by: Annorax
1 Replies

3. UNIX for Dummies Questions & Answers

Compiling UNIX software packages Question

I am trying to learn how compile programs using this lesson. UNIX Tutorial Seven I am stuck at 7.4 Configuring and creating the Makefile. It stats that I need to configure the utility with my home directory. After doing the echo $HOME command I get /home/Bill_Gates. It then says to insert... (6 Replies)
Discussion started by: jae99
6 Replies

4. Linux

running java program question

hi, i have just written a simple hello world java program in my linux server, installed jdk ... and tried to compile and run it and it gave me some errors. please details below: # cat HelloWorld.java import java.util.*; import java.io.*; public class HelloWorld { public static void... (4 Replies)
Discussion started by: k2k
4 Replies

5. Programming

Java Compiling Help**URgent**

I am compling simple java program HelloWorld.java although /usr/bin @ this path javac is present, is there any command line wherein i can pass the this option as well lik javac -opttion(javac path) filename.java as i do not have permissions to set path. Also wht does this error, means...... (0 Replies)
Discussion started by: niceboykunal123
0 Replies

6. Solaris

Java / SunOS Security question

Hi, I have a question about the Java that comes with the Solaris 9/10 OS. All my boxes are servers, only ssh allowed, no x windows, hardened, firewaled, etc... Their purpose is Oracle DB's and Sun One Dir servers. None of which use the OS version of Java as far as know. Question IS, can... (1 Reply)
Discussion started by: BG_JrAdmin
1 Replies

7. Shell Programming and Scripting

Simple Shell Script Question.... [java related]

Hey guys! This is my first post, as im new here :S I have a simple problem for a big program. We have a .sh to install it, but when I run the .sh in terminal like i should, It says the class is not found. I believe it has to do with the syntax, as the person who made it is not a linux pro. I... (3 Replies)
Discussion started by: Drags111
3 Replies

8. UNIX for Dummies Questions & Answers

Java compiling error

I need Help folks; I'm very new to Java & i was trying to compile some java files & i got a lot of errors (see below), could some one tell me what am i doing wrong? These are the files i need to compile: AddCommentActionLogging.java EditPageActionLogging.java When i run:... (4 Replies)
Discussion started by: Katkota
4 Replies

9. Shell Programming and Scripting

Newbie Question: passing a variable into java from script?

I'm currently working on my second ever ksh script! So I apologize if this is a stupid question - I've searched the forum and on google and haven't seen anything :confused: I'm running my script with an input at startup that variable determines a couple of other values(int) that I store into... (1 Reply)
Discussion started by: Cailet
1 Replies

10. Programming

Question about compiling (noob)

I'm just getting started to lean C and I'm using Ubuntu today I found a tutorial at this site: http://einstein.drexel.edu/courses/CompPhys/General/C_basics/c_tutorial.html and I got an error after compiling the fist code: #include < stdio.h> void main() { printf("\nHello World\n"); } ... (9 Replies)
Discussion started by: arya6000
9 Replies
Login or Register to Ask a Question