Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Basics Using your New Tools Coding the Prototype

Siu KWAN Yuen
PLUS
Siu KWAN Yuen
Courses Plus Student 2,898 Points

"Javac" <- command not found

I tried the code with my own bash, and it failed to compile the document

5 Answers

If you can compile in the IDE you must have the JDK installed.

The javac command isn't automatically usable at every command prompt or PowerShell. You need to add it to your environment variables and the path. Google that - it's easy to do.

Also, you can navigate to the folder location of javac.exe. Go to C:\Program Files\Java\jdk<version>\bin and run javac using a bash call like ./javac - that'll give you all its available options. You can add a path to the source file to compile it directly.

I hope that helps,

Steve.

Siu KWAN Yuen
Siu KWAN Yuen
Courses Plus Student 2,898 Points

Thank you Steve. I guess it is the PATH or bin kind of problem, isn't it? I may as well just let it go; the problem seems too complicated.

Yes, amending your path will enable your to use javac at any command prompt. But it is all a bit of a chore! You can probably use the java console inside Netbeans too? Or just stick to Workspaces!

Siu KWAN Yuen
Siu KWAN Yuen
Courses Plus Student 2,898 Points

You 're right. Sticking to workspaces is probably a good idea. I feel much solid knowing that the knowledge I learned is "reproducible", despite the fact that the linux things always stress me out. I once thought of buying a new computer and installing linux given that my computer isn't fast anymore.

Workspaces will definitely do what you want it to as it is pre-loaded with everything you need.

This machine I use triple boots; one to Windows 10, one to Fedora Core Linux and another option to Kali Linux. It is useful to get proficient in Linux terminal but not essential. You will come across it at some point, though, especially if you want to manage web servers as many use Apache on Linux.

Siu KWAN Yuen
PLUS
Siu KWAN Yuen
Courses Plus Student 2,898 Points

I already used "javac" and it is still not working. It returns: bash: javac: command not found

What OS are you using and have you installed the JDK?

Siu KWAN Yuen
Siu KWAN Yuen
Courses Plus Student 2,898 Points

Windon 10. I am not sure if I have installed JDK, but I have IDE on my computer.

OK - which IDE?

As well as what IDE are you using, in PowerShell - what happens if you type java -version?

Siu KWAN Yuen
Siu KWAN Yuen
Courses Plus Student 2,898 Points

I think it's NetBeans IDE 8.2. I can compile files using IDE, but I am just curious about how he did it via the prompt stuff. I feel not confident if I cannot remake what I have been learned

Java is a case-sensitive language. Use "javac" instead of "Javac".

Sadly, I tested this - Javac works just fine, as did javAC. I'm not sure that this is anything to do with Java being case sensitive, or otherwise, rather than the environment managing the terminal being ambivalent as to case.

Siu KWAN Yuen
PLUS
Siu KWAN Yuen
Courses Plus Student 2,898 Points

Wouldn't it slow your computer down? I had installed a virtual machine once but at that time I knew it would consume my computer resources, so I hesitated and decided not to use it.

A VM will use a lot of resources - I use VMs for various reasons; they are very useful if a little resource hungry. Having a triple booted machine doesn't slow anything down, no. It only boots into one OS at a time. So, I use Windows for general use and Office applications and the familiarity! I use Fedora Core for development work and Kali Linux for penetration testing/ethical hacking. Only one OS is in use at once, although I have a Kali VM available in Fedora for instance when I want to run attacks against an Apache server running on Linux. The only resource the multiple booting takes up is disk space, so my 1TB drive is divided into 3 with a partition for each operating system.

Siu KWAN Yuen
PLUS
Siu KWAN Yuen
Courses Plus Student 2,898 Points

It is great having a super-computer to do everything we need. I feel like having a desktop as opposed to a notebook. It seems like notebooks commonly have smaller disk space and a higher price.

I've got three machines. The desktop tower, as described and two laptops. One is a Macbook running OSX and Kali in a VM. It also dual boots into Kali Linux, quite effectively - that hard drive is large enough to cope. Macbook is not cheap, though. The third machine is a Windows laptop that I use to test vulnerability attacks against Windows.

The tower represents good value for money. If you get one without an OS and rely on Linux for free, that's very good value indeed.