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

What is the best way to code java using the console as a Windows user outside Workspace.

(new to programming) So Treehouse makes you use Workspace to start learning Java to simulate working from a console, I know I can code using an IDE but they want you to refrain from using one at first to learn the basics, which is fine but Treehouse doesn't touch much on how would one would go into using the console to code. Workspace has 2 windows one for code and the console which loads the code. My question is where would one write the java code outside workspace if its not an IDE; Notepad?? and as a Windows user how could I load said code into the command prompt, or Git Hub; I downloaded it created a class from my java file using the $ javac file.java command but when I tried running it using $ java file the console gives me a bash noclassdeffounderror..... is there a better way to simulate what workspace is doing, how do Windows users work with java in consoles in the real world.

2 Answers

here is course about IDE https://teamtreehouse.com/library/local-development-environments

if you installed the JDK then you can use the CMD to execute java file without an IDE first go to the specific folder using cd command and then you can use javac and java without the dollar sign

check these http://www.skylit.com/javamethods/faqs/javaindos.html and https://www.youtube.com/watch?v=H-g-byFq-Hs

Joseph Wasden
Joseph Wasden
20,406 Points

My question is where would one write the java code outside workspace if its not an IDE; Notepad??

You can write the code anywhere, really. It won't do much on your computer though until you have the Java Development Kit (JDK) installed and use that installation of Java to compile and run the code you wrote. Remember the javac command you type in the console, followed by your code file? That is a command telling the JDK to compile your human readable (and human written) Java code into Java BYTEcodes, which you would have a hard time reading because you aren't a computer. when you run the Java console command followed by your newly compiled bytecode filename, you are using a command that comes with the JDK to tell the Java Virtual Machine (JVM) to run the compiled code.

so, to recap:

  • you can write code anywhere.
  • that code will not "run" until it is compiled.
  • you have to install the JDK to compile your written code.
  • After compiling your code, you can run it in the JVM (which you will have installed at the same time as the JDK)

It sounds like you still need to install Java. Type the following into your console and press enter.

java -version

if it didn't return a version of java, then you still need to install java. Check this place out to get started.

https://www.java.com/en/download/help/download_options.xml