Solved

All I wanna do is COMPILE!!!

Posted on 2001-06-16
13
250 Views
Last Modified: 2013-11-23
Hi everyone.  This is as novice as it gets.  I'm just starting my journey down the Java 2 road and I need to compile my first example.  Its not working.  I am running windows 98 and created my .java file in homesite and trying to use javac under JDK 1.3.1.  I choose "Run" from the "Start" menu and type "javac MyFirstApplet.java" like the book tells me to.  I then get an error that says "Cannot find the file 'javac'(or one of its components).  Make sure the path and filename are correct and that all required libraries are available."  I have tried changing the path to many different things.  Please.  Anyone know whats goin on??  If you think this question is worth more, please tell me.  Thank you.
0
Comment
Question by:slickrick001
  • 4
  • 3
  • 3
  • +3
13 Comments
 
LVL 4

Expert Comment

by:k.jones
ID: 6199271
Your 'path' should contain 'C:\JDK1.3.1\bin' if you wish to compile using javac.  Does it?

Cheers,
Ken Jones
0
 
LVL 1

Expert Comment

by:boazbl1
ID: 6199370
Try using the explicit path e.g.
c:\jdk1.3.1\bin\javac MyFirstApplet.java
0
 
LVL 10

Expert Comment

by:Nushi
ID: 6199476
the answer is to set classpath as already said before.
try to work with application like Visual j++ or Kawa which can help you very much at the begining.

also take a look at the following link:
http://java.sun.com/j2se/1.3/install-windows.html#Environment
http://java.sun.com/j2se/1.3/docs/tooldocs/win32/classpath.html

Nushi.

0
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 

Expert Comment

by:crazyburns
ID: 6200509
There are two different paths to set for the JDK.  There is the PATH and the CLASSPATH.  These are different.
The path points to the javac and java programs which should be in the C:\JDK1.3.1\bin folder (or wherever you installed the JDK).  The CLASSPATH points to the classes used by your program.  The best thing to set the CLASSPATH to is just "CLASSPATH=" This will cause java to look in the current directory and then in its own directorys for the classes used by your program.  The best idea is to put these declarations in your AutoExec.BAT file and then restart your computer.  This will make it so that these work every time now.
0
 
LVL 4

Expert Comment

by:k.jones
ID: 6200622
The original post states that javac was not found.  This is a path problem (assuming JDK is installed).  The classpath is irrelevant if javac cannot be found.

Cheers,
Ken
0
 

Expert Comment

by:rameshnut
ID: 6201076
Hi slickRick001  

I suggest you do the following

step 1) Go to the Jdk1.2\bin or Jdk1.3 \bin directory
(if you had installed jdk you should not have problems reaching that directory.
(this step number 1 is to ensure that you INDEED installed jdk on your system :-)


step 2) Just open a dos window and go the jdk1.2\bin or jdk1.3 bin directory.then enter javac at the command prompt (and nothing else!) and see if its get executed.if it does...it shows the usage of javac.

step3) having done thru these steps.
just go the root directory c: and edit the autoexec.bat file ,just add the following line as the last one in your autoexec.bat file

%path%;c:\jdk1.2\bin
(if you have jdk1.3 then add the following line instead of the above )
%path%;c:\jdk1.3\bin

step 4) SAVE THE AUTOEXEC.BAT FILE.

step 5) RESTART THE SYSTEM.(you must do it)

IF this works, i will you why YOUR PREVIOUS approach didnt work!..do try it now !

Dont BOTHER ABOUT ANY CLASSPATH.IF YOU HAVE PREVIOUSLY SET ANYCLASS PATH, UNSET IT.

ITS A MISTAKE TO SET CLASSPATH IN JDK 1.2  AND ABOVE VERSIONS FOR FINDING CORE JAVA CLASSES :-)

rameshnut
0
 

Author Comment

by:slickrick001
ID: 6208455
I put it what you said Rameshnut, but I'm getting the same error.  I bet I did something wrong.  Heres what my autoexec.bat file lloks like:

SET BLASTER=A220 I7 D1 T2
SET SNDSCAPE=C:\WINDOWS


PATH=%PATH%;"C:\Program Files\Mts"
%path%;c:\jdk1.3.1\bin

I put my .java file in the bin directory in hopes that it would make a difference.  Doesn't seem to.  Am I screwing something up???  This is quite frustrating.
0
 
LVL 4

Expert Comment

by:k.jones
ID: 6208513
Enter,

C:\JDK1.3.1\bin\javac <your-java-file>

If windows still reports that it cannot find javac, then you do not have the JDK installed correctly.  If this is the case, uninstall and start all over.

Put your path statement back to whatever it was before you started and enter,

path = %path%;c:\JDK1.3.1\bin

and then try to run javac.

Cheers,
Ken
0
 

Accepted Solution

by:
rameshnut earned 50 total points
ID: 6210884
hi slickrick001


just a correction

when i meant add the path .. %path%;c:\jdk1.2\bin

i meant you to add it as follows

path = %path%;c:\jdk1.2\bin
or
path = %path%;c:\jdk1.3\bin

as the last sentence.

since you have even tried to compile the java file from the bin directory.please see if the javac.exe EXISTS!!.
if not!..your installation program has screwed up something (and not you!!!)
so install the jdk again and dont forget to add the path to your autoexec. and follow the procedure i told you previously

good luck!

rameshnut
0
 

Author Comment

by:slickrick001
ID: 6231690
Okay.  This is it.  You have all helped me too much already.  I've geven this a fresh start.  I'm at a friends computer (Win ME).  I installed JDK 1.3.1.  Java is indeed in the bin directory.  I followed the directions from Sun's website as to how to set the Path, it was easy enough.  *With a Run prompt, I can run Javac.  It comes up and goes away too fast though*  I made a new file MyFirstApplet.class and typed this from a Run window...

javac MyFirstApplet.class

It seems to work. No errors for once.  It goes away too fast though.  There is no .java file after that.  I have looked for it and run searches but to no avail.  So.  Any idea what I'm doing wrong ova here?  I apologize for the rediculousness of all this but I greatly appreciate everyones effort.
0
 

Author Comment

by:slickrick001
ID: 6231863
Wait.  Sorry.  I changed the .class to .java and then compiled it.  A .class WAS CREATED!!!!  Of course, it doesn't work even though the coe was copied from the book.  Since I haven't gotten one example to work, I should just make sure this is right.  the code is...

import javax.swing.JApplet;
import java.awt.Graphics;

public class MyFirstApplet extends JApplet
{
public void paint (Graphics g)
     {
     g.drawString("To climb a ladder, start at the bottom rung", 20, 90);
     }
}    

This is my last question.  I wouldn't be asking code issues if I had gotten previous ones to work.
0
 

Author Comment

by:slickrick001
ID: 6236364
It looks like I'm trying to get more answers with one quesion.  I definately don't want to be accused of that.  Thank you all very much.
0
 

Expert Comment

by:rameshnut
ID: 6237233
Thanks slickrick001 :-)
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question