1843874 Members
5975 Online
110225 Solutions
New Discussion

Java Question

 
SOLVED
Go to solution
Kyle D. Harris
Regular Advisor

Java Question

I'm setting up a server and in a step i got off a web page i'm going by it says this:

Compile the source into a class file as follows:

javac -classpath /usr/local/jakarta-tomcat/common/lib/servlet.jar HelloWorld.java
This will create a file called HelloWorld.class. Copy the HelloWorld.class file to the /home/tomcat/your_application/WEB-INF/classes directory.

*** When i do this i get a "bash: javac: command not found "...... why is this? The site i'm going off of is spefiically for configuring apache and tomcat for RH 9.0 which i have. Thanks ..

14 REPLIES 14
Kyle D. Harris
Regular Advisor

Re: Java Question

I just read something on a board.. Do i need the Java 2 sdk installed to be able to do this javac command?
Steven E. Protter
Exalted Contributor

Re: Java Question

At the very least it appears you need Java Run Time which is a subset of JDK.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Kyle D. Harris
Regular Advisor

Re: Java Question

I'm having alot of trouble trying to find somewhere to download this Java 2 SDK ... I'm looking around on sun.java.com but haven't seen anything for RH 9.0 yet. If anybody can send a direct link that'd be great. I'll keep looking. Thanks.
Jerome Henry
Honored Contributor

Re: Java Question

Yes,
you need java run time to interpret java code as a client, and java sdk to compile your own java progs.
J
You can lean only on what resists you...
Jerome Henry
Honored Contributor

Re: Java Question

http://java.sun.com/j2se/1.4.2/download.html
Go for sdk part.

J
You can lean only on what resists you...
Kyle D. Harris
Regular Advisor

Re: Java Question

I just did a "find / -name *sdk* " and i came up with 'j2sdk1.4.1' which i have already installed.

If that is already installed then what part do i still need? The JRE download??? Thanks.
Mark Grant
Honored Contributor

Re: Java Question

Kyle, do you have a "javac" anywhere in that directory?

If so, just add that directory to your PATH or type the full path name to "javac"

Regards
Never preceed any demonstration with anything more predictive than "watch this"
Kyle D. Harris
Regular Advisor

Re: Java Question

Hmm actually Mark, in that directory after j2sdk1.4.1/bin there is javac in there. I'll try putting it in my path.
Kyle D. Harris
Regular Advisor

Re: Java Question

I'm not real experienced so correct me if I'm wrong but you mean like this:

*prompt*# /usr/java/j2sdk1.4.1/bin/javac -classpath /usr/local/jakarta-tomcat/common/lib/servlet.jar HelloWorld.java

?? Thanks for the help.
Kyle D. Harris
Regular Advisor

Re: Java Question

After running what i posted in my last post, it paused for a second and gave this:

error: cannon read: HelloWorld.java
1 error

Martin P.J. Zinser
Honored Contributor
Solution

Re: Java Question

Hello Kyle,

to clarify some terminology. Java is a programming language starting from text source code, which is compiled to a bytecode format, which is then executed. If all you want to do is execute programs that other people already compiled you only need the part interpreting the bytecode. This is the so called runtime environment or JRE. If you want to compile text source code yourself you need a SDK (software developers kit). The SDK is a superset of the JRE, i.e. all the functionality of the JRE is also part of the SDK.

Try to put the bin directory into your path for ease of use. Using this will cut down the overlong commands you have now considerably.

As for the last error you are getting, are you sure you have a HelloWorld.java in your current working directory?

Greetings, Martin
Bruce Copeland
Trusted Contributor

Re: Java Question

Kyle:

Make sure that HelloWorld.java is located in the directory from which you are executing the javac command. Also make sure that the permissions on the file give read access. If HelloWorld.java is located somewhere else, you either need to cd to that directory before giving the javac command, or you need to add a -sourcepath option specifying where your source is located. (Type javac -h to get more detail about command options.)

Bruce
Olivier Drouin
Trusted Contributor

Re: Java Question

in /etc/profile or ~/.profile, Add:

PATH=$PATH:/usr/java/j2sdk1.4.1/bin
export PATH

I'd say you get the last error because you .java was not in the same dir that you issued you command.
Kyle D. Harris
Regular Advisor

Re: Java Question

Problem Solved. I wasn't in the directory where my HelloWorld.java was in. OOps! Thanks to all who responded.

Kyle