This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer (Exam 1Z0-830) Java SE 17 Developer (Exam 1Z0-829) Programmer’s Guide and have Khalid Mughal and Vasily Strelnikov on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

javac won't compile

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am beginning java. I just downloaded the jdk. I wrote the "Hello, world!" program and saved it. I put the path in, but when I do javac HelloWorld.java it get a message saying I don't have javac.
 
Ranch Hand
Posts: 417
Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just a path problem maybe.

Search for setting path.

On unixes it goes like:

PATH=${PATH}:<your jdk binfolder>
export PATH

On Windows, I think it goes like:
PATH=%PATH%;<your jdk binfolder>

Which OS are you on? A Unix flavor, Windows, etc. ?
 
Marshal
Posts: 80656
477
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

You should put the new Java® location at the beginning of the PATH environment variable. That way you shouldn't have the problem of using a newer version of javac than of java. We have an FAQ which tells you how to set the PATH.
There is a slightly different technique in the Oracle installation instructions.
 
Campbell Ritchie
Marshal
Posts: 80656
477
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please tell us what your new PATH is, as shown by the following instructions:-
echo %PATH% (Windows)
echo $PATH (Linux/Unix)
Also: did you start a new terminal/command prompt?
 
Carlos Monge
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am brand new to Java. The book, Java Programming for Absolute Beginners, say to set the path at the end of the Edit System Variables line. This is what I put

C:Program Files\Java\jdk1.8.0-60\bin;

When I try to run my Hello World program with - javac HelloWorld.java I get this message

javac: file not found: HelloWorld.java
usage: javac <options> <source files>
use -help for a list of possible options


I use -help and it tells me

'-help' is not recognized as an internal or external command,
operable program or batch file.

I am lost.
 
author
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carlos Monge wrote:
When I try to run my Hello World program with - javac HelloWorld.java I get this message

javac: file not found: HelloWorld.java
usage: javac <options> <source files>
use -help for a list of possible options




The error message is saying that it can't find the HelloWorld.java file. Do you have a HelloWorld.java file?

Carlos Monge wrote:
I use -help and it tells me

'-help' is not recognized as an internal or external command,
operable program or batch file.

I am lost.




Did you run "javac -help"? Or did you just run "-help"? ...

Henry
 
Campbell Ritchie
Marshal
Posts: 80656
477
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you say 8.0-60? Surely it is 8.0_60. Underscore not dash.
 
Campbell Ritchie
Marshal
Posts: 80656
477
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are getting erors like
javac: file not found
… then you have probably set a PATH which works (underscore or not). There are problems finding the .java file. Please print the location and contents of your java folder (use the dir command).
 
Campbell Ritchie
Marshal
Posts: 80656
477
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also please print the result of
echo %CLASSPATH%
You should usually not set a system CLASSPATH; it usually does more harm than good, and may prevent you finding your own files.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carlos Monge wrote:C:Program Files\Java\jdk1.8.0-60\bin;


Is that exactly what you put in the PATH? I see at least two errors in there.

C:\Program Files\Java\jdk1.8.0_60\bin;

Also, do not replace the complete PATH with that, but put that in front of what's already in PATH.

Replacing everything in PATH (deleting what's already there) can mess up your system!
 
Carlos Monge
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I posted the path to the front of the Path in System. I found this C:\ProgramData\Oracle\Java\javapath; already there. I don't know how it got there.

Someone asked what I'm using.
I have an HP with Windows 10.

I tried it after I moved the C: \Program Files\Java\jdk1.8.0_60\bin; to the front. It still didn't work.

I made a command prompt as directed in the book and went to C:\Program Files\Java\jdk1.8.0_60\bin. I then called for notepad and wrote the HelloWorld program. I saved it as a .java file, but I still can't get it to compile.
I keep getting messages that the computer can't find javac.
 
Henry Wong
author
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carlos Monge wrote:
I keep getting messages that the computer can't find javac.



Really?!? In your previous post, the message was a javac error message saying that it can't find the java source file. So, there was a few cases where it did find javac -- or you would not have gotten a javac error.

What did you do to get it to work (find javac)? And what did you do to break it again?

Henry
 
Campbell Ritchie
Marshal
Posts: 80656
477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If there is a javapath folder you can always look in it and see what it contains, with Windows Explorer, but it is probably in the PATH for a good reason. Don't try to change it.

s Henry and I have said, you would appear to be finding javac after all. Try
javac -version
java -version

You should get the same version for each, but the second instruction usually prints some more information. You would appear to have lost your Java® work. Please print your current working directory, and its contents (with the dir command).
 
Carlos Monge
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is what I get when I dir

Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Users\cmongeoroplata09>cd C:
C:\Users\cmongeoroplata09

C:\Users\cmongeoroplata09>cd Program Files
The system cannot find the path specified.

C:\Users\cmongeoroplata09>cd \Program Files

C:\Program Files>cd \Java
The system cannot find the path specified.

C:\Program Files>cd Java

C:\Program Files\Java>cd jdk1.8.0_60

C:\Program Files\Java\jdk1.8.0_60>cd bin

C:\Program Files\Java\jdk1.8.0_60\bin>javac HelloWorld.java
javac: file not found: HelloWorld.java
Usage: javac <options> <source files>
use -help for a list of possible options

C:\Program Files\Java\jdk1.8.0_60\bin>javac -version
javac 1.8.0_60

C:\Program Files\Java\jdk1.8.0_60\bin>javac -version
javac 1.8.0_60

C:\Program Files\Java\jdk1.8.0_60\bin>dir
Volume in drive C is OS
Volume Serial Number is 3436-38AF

Directory of C:\Program Files\Java\jdk1.8.0_60\bin

08/29/2015 03:53 PM <DIR> .
08/29/2015 03:53 PM <DIR> ..
08/29/2015 03:53 PM 15,936 appletviewer.exe
08/29/2015 03:53 PM 16,448 extcheck.exe
08/29/2015 03:53 PM 16,448 idlj.exe
08/29/2015 03:53 PM 33,856 jabswitch.exe
08/29/2015 03:53 PM 15,936 jar.exe
08/29/2015 03:53 PM 16,448 jarsigner.exe
08/29/2015 03:53 PM 15,936 java-rmi.exe
08/29/2015 03:53 PM 206,912 java.exe
08/29/2015 03:53 PM 15,936 javac.exe
08/29/2015 03:53 PM 16,448 javadoc.exe
08/29/2015 03:53 PM 133,696 javafxpackager.exe
08/29/2015 03:53 PM 15,936 javah.exe
08/29/2015 03:53 PM 15,936 javap.exe
08/29/2015 03:53 PM 133,696 javapackager.exe
08/29/2015 03:53 PM 206,912 javaw.exe
08/29/2015 03:53 PM 322,112 javaws.exe
08/29/2015 03:53 PM 15,936 jcmd.exe
08/29/2015 03:53 PM 16,960 jconsole.exe
08/29/2015 03:53 PM 16,448 jdb.exe
08/29/2015 03:53 PM 15,936 jdeps.exe
08/29/2015 03:53 PM 15,936 jhat.exe
08/29/2015 03:53 PM 16,448 jinfo.exe
08/29/2015 03:53 PM 15,936 jjs.exe
08/29/2015 03:53 PM 174,656 jli.dll
08/29/2015 03:53 PM 16,448 jmap.exe
08/29/2015 03:53 PM 321,600 jmc.exe
08/29/2015 03:53 PM 417 jmc.ini
08/29/2015 03:53 PM 15,936 jps.exe
08/29/2015 03:53 PM 16,448 jrunscript.exe
08/29/2015 03:53 PM 16,448 jsadebugd.exe
08/29/2015 03:53 PM 16,448 jstack.exe
08/29/2015 03:53 PM 15,936 jstat.exe
08/29/2015 03:53 PM 15,936 jstatd.exe
08/29/2015 03:53 PM 196,672 jvisualvm.exe
08/29/2015 03:53 PM 16,448 keytool.exe
08/29/2015 03:53 PM 16,448 kinit.exe
08/29/2015 03:53 PM 16,448 klist.exe
08/29/2015 03:53 PM 16,448 ktab.exe
08/29/2015 03:53 PM 829,264 msvcr100.dll
08/29/2015 03:53 PM 16,448 native2ascii.exe
08/29/2015 03:53 PM 16,448 orbd.exe
08/29/2015 03:53 PM 16,448 pack200.exe
08/29/2015 03:53 PM 16,448 policytool.exe
08/29/2015 03:53 PM 15,936 rmic.exe
08/29/2015 03:53 PM 15,936 rmid.exe
08/29/2015 03:53 PM 16,448 rmiregistry.exe
08/29/2015 03:53 PM 16,448 schemagen.exe
08/29/2015 03:53 PM 16,448 serialver.exe
08/29/2015 03:53 PM 16,448 servertool.exe
08/29/2015 03:53 PM 16,448 tnameserv.exe
08/29/2015 03:53 PM 197,184 unpack200.exe
08/29/2015 03:53 PM 15,936 wsgen.exe
08/29/2015 03:53 PM 16,448 wsimport.exe
08/29/2015 03:53 PM 16,448 xjc.exe
54 File(s) 3,440,113 bytes
2 Dir(s) 698,488,082,432 bytes free

C:\Program Files\Java\jdk1.8.0_60\bin>
 
Campbell Ritchie
Marshal
Posts: 80656
477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are in the wrong location. Don't put any of your work in the bin folder; it may cease to exist when you update to a new version of Java®. Create a folder to keep your work in, as shown in this post.
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Campbell says, do not put your source files in the bin directory of the JDK.

Some other points to check:

- Make sure there are no extra spaces before or after the entry "C:\Program Files\Java\jdk1.8.0_60\bin;" in the PATH. For example, there must be no spaces before or after the ;.
- After changing the environment variables in Windows system settings, you must close and re-open the command prompt window. It will not pick up the change while the command prompt window is open.

What exactly do you get as output from the command:

echo %PATH%

This prints the current setting of the PATH environment variable.
 
Campbell Ritchie
Marshal
Posts: 80656
477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also please show us what happens when you look for the classpath
echo %CLASSPATH%
You should not usually set a system classpath at all, so you should get no printout from that. Please use copy‑and‑paste to show us the environment variables, as described in this FAQ.

I suspect you are looking for your .java file in the wrong location.
 
Campbell Ritchie
Marshal
Posts: 80656
477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I merged your stuff with the following thread. I hope that is okay by you.
 
Carlos Monge
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am about to give up on Java and try Python.

I've change my folder to save in Documents\Chapter01 and my path is the same.

When I try to compile, I get

'javac' is not recognized as an internal or external comman,
operable program or batch file.

I've used notepad as the book suggested from the command line in the folder where the file is saved.
I used Notepad++ for the MooseGreetins. Both files are in the forlder, but still get not navac message.
 
Campbell Ritchie
Marshal
Posts: 80656
477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What have you done? Have you upgraded Java® and not updated your system PATH?
 
Campbell Ritchie
Marshal
Posts: 80656
477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where did you install Java®? What happens when you write these four instructions? Copy and paste the output as shown here. We can probably help you sort out the problem.
echo %PATH%
echo %CLASSPATH%
java -version
javac -version


Don't add your questions to somebody else's thread; that is called hijacking, and has caused confusion here, too.
 
Campbell Ritchie
Marshal
Posts: 80656
477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what is going on? Some of the time you tell us you cannot find javac, then you give us error messages which could only be caused by your finding javac. Stop going round in circles and show us the four printouts I asked for a few minutes ago.
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
whenever you type a command on the command line, the Operating system has to find the program you are trying to run. I think windows, by default, looks in the current directory. If the program isn't there, then it looks in every directory listed in your PATH environment variable to see if it is in any of those. It looks in order, and quits looking as soon as it finds a match (which is why Campbell said to put the new path first).

So....

if you just installed the JDK and didn't update your PATH, Windows won't know where to find "javac" - unless you had cd'd into the directory and then typed "javac". That may be why sometimes you can get it to work and not others.

If you are here:

C:\>

and you type "javac -version" (without the quotes), do you get a "javac is not recognized..." or do you get something like "javac 1.7.0"?

That is the first problem we'd need to solve.
 
Carlos Monge
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here are the four printouts you asked for.

Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Users\cmongeoroplata09>echo %PATH%
C:\Users\cmongeoroplata\Documents\Chapter01;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\ArcSoft\Bin;;C:\mozart\bin;C:\emacs\bin;C:\Program Files (x86)\QuickTime\QTSystem\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\MinGW\bin

C:\Users\cmongeoroplata09>echo %CLASSPATH
%CLASSPATH

C:\Users\cmongeoroplata09>java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

C:\Users\cmongeoroplata09>javac -version
'javac' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\cmongeoroplata09>

C:\Users\cmongeoroplata09>

C:\Users\cmongeoroplata09>
 
A.J. Côté
Ranch Hand
Posts: 417
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carlos Monge wrote:Here are the four printouts you asked for.

Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Users\cmongeoroplata09>echo %PATH%
C:\Users\cmongeoroplata\Documents\Chapter01;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\ArcSoft\Bin;;C:\mozart\bin;C:\emacs\bin;C:\Program Files (x86)\QuickTime\QTSystem\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\MinGW\bin

C:\Users\cmongeoroplata09>echo %CLASSPATH
%CLASSPATH

C:\Users\cmongeoroplata09>java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

C:\Users\cmongeoroplata09>javac -version
'javac' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\cmongeoroplata09>

C:\Users\cmongeoroplata09>

C:\Users\cmongeoroplata09>



Maybe you only have JRE installed or at least only JRE in your PATH. You need to have JDK installed and in your PATH in order for your shell to find javac:

Examples:

No javac in here!!!


javac is there.

Fix your PATH and install jdk if you only have jre installed.

 
Campbell Ritchie
Marshal
Posts: 80656
477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
AJC is probably correct. Note the format he has shown you is typical for a Unix/Linux box; the names are slightly different on Windows.

You should write
echo %CLASSPATH%
with % at the end. You wrote
echo %CLASSPATH
so the output does not help you.

Why do you have the first element in your PATH? I am sure C:\Users\cmongeoroplata\Documents\Chapter01 should not be there. Did you add it yourself? If so remove it.
It is possible that C:\ProgramData\Oracle\Java\javapath is also there by mistake. Did you add it yourself? If so, remove it.
You do not have anything looking like a Java installation folder in your system PATH. I don't know how you managed to get the can't find file errors from javac.

Use Windows Explorer or similar and go to C→Program Files→Java→jdk1.8.0_60→bin. See what programs you have in that folder. You should find things like appletviewer.exe, java.exe and javac.exe.
If you can't find anything try going here and downloading and reinstalling Java®. You must install the JDK (Java SE Development Kit) not the JRE. Note carefully where it says it is installing it. That will probably be
C:\Program Files\Java\jdk1.8.0_60
If that is the case then add
C:\Program Files\Java\jdk1.8.0_60\bin and a semicolon ; to the start of your current system PATH, and open a new command line. Be careful to note the spelling on your machine, in case it is different from what I wrote.
 
Carlos Monge
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My Java\jdk1.8.0_60\bin has the appletviewer.

It has a java and javac file but now java.exe ore javac.exe.

I guess I have to uninstall and reinstall.


 
A.J. Côté
Ranch Hand
Posts: 417
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carlos Monge wrote:My Java\jdk1.8.0_60\bin has the appletviewer.

It has a java and javac file but now java.exe ore javac.exe.

I guess I have to uninstall and reinstall.




Right click on javac and click on properties to see what it says. Windows used to hide file extensions by default.

Otherwise, you have managed to install a Unix version of the jdk on Windows, which is feasible if you download the zip file.

Maybe your java command works because of some other JRE only install. Then you would have to include the windows jdk path in your PATH.
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carlos Monge wrote:Here are the four printouts you asked for.

Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Users\cmongeoroplata09>echo %PATH%
C:\Users\cmongeoroplata\Documents\Chapter01;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\ArcSoft\Bin;;C:\mozart\bin;C:\emacs\bin;C:\Program Files (x86)\QuickTime\QTSystem\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\MinGW\bin


There's no C:\Program Files\Java\jdk1.8.0_60\bin in your path.

Assuming you've installed the JDK (and not only the JRE), you haven't set the PATH environment variable correctly.
 
Campbell Ritchie
Marshal
Posts: 80656
477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you can find javac or javac.exe in the bin folder then you have almost certainly installed the JDK and only need to update your PATH. Try the following instruction at a command line:-
set PATH="C:\Program Files\Java\jdk1.8.0_60\bin";%PATH%
You need "quote marks" because there is a space in the instruction. Check my spelling very carefully because I might have got it wrong.
Then navigate to the folder where your .java files are and try to compile them again with the javac tool.

I think it is unlikely that you have installed a Unix version of Java®. I think Jesper is correct that you have simply not set your system PATH correctly. The instruction I have just given you should correct that mistake.
 
Campbell Ritchie
Marshal
Posts: 80656
477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

A few minutes ago, I wrote:. . . The instruction I have just given you should correct that mistake.

But that correction will only apply to that particular instance of the command line.
 
A.J. Côté
Ranch Hand
Posts: 417
Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To convince yourself that your javac is working without configuring your PATH,

If javac is located at:

C:\Program Files\Java\jdk1.8.0_60\bin\javac

Just cd to the folder where your source file is and type:

C:\Program Files\Java\jdk1.8.0_60\bin\javac YourClass.java

This should working without even setting your PATH.
 
Carlos Monge
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to thank everyone for their help. I reloaded Java and it works now. Be sure that, since I am new, I will be back here.
 
Carlos Monge
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry A.J. Côté, I somehow ended up giving you a -1 when I meant to give you a +1. I tried to fix it but don't know how. Another thing I have to learn.
 
reply
    Bookmark Topic Watch Topic
  • New Topic