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
Nenad Jovic
7,883 PointsCan someone help me with Command prompt doubts
Hello,
I have some assignment to do to practice, but for some reason it's not working in command prompt, it's not opening/
I created folder called "Add.java" and as well i did put code above in text file "Add.java"
and when i try to open it i get error http://prntscr.com/5mzt5e
P.S. Here is full question of my assignment exercise http://prntscr.com/5mzukq
3 Answers
Dan Johnson
40,533 PointsBefore you can run the code, you'll need to compile it. Calling javac with the path to the file will do this:
javac D:\Add.java\Add.java
Then you can call java on the .class file that was generated (without the .class extension):
java Add
If you call java outside the directory the .class file is in, you'll need to specify the path with the classpath option:
java -cp D:\Add.java Add
I'd recommend not adding the file extension in the directory name, as it causes confusion to what you're actually referring to.
Nenad Jovic
7,883 PointsStill got problem http://prntscr.com/5o1qoo
Dan Johnson
40,533 PointsYou need to add the classpath option (like in the last example) since you're calling from C:\Documents and Settings\sone
Nenad Jovic
7,883 PointsAh, yes it works now! ^^ Thanks man <3