4

it's a good doc for people who first use java but meet about command line i have a few questions https://lift.cs.princeton.edu/java/windows/

His terminal code like this:

~/Desktop/hello> ls
Barnsley.java  COS 126.iml    WELCOME.txt    logo.png
~/Desktop/hello> javac-introcs Barnsley.java
~/Desktop/hello> java-introcs Barnsley 10000

but in my idea,it uses cmd.exe so ls should be replaced dir i know but when i type javac-introcs Barnsley.java it tells me

'java-introcs' is not an internal or external command, nor is it a runnable program
Or a batch file.

enter image description here

3
  • java-introcs is clearly something the instructor wrote (could be an alias) -- it is not a Java command. Intro cs (introduction to cs?) must add the various parameters. I suspect that just javac and java would be sufficient, though whether the instructor's commands added a classpath or something cannot be readily determined.
    – KevinO
    Oct 11, 2018 at 15:41
  • the prompt (~/Desktop/hello>) isn't a typical cmd prompt, so your idea might be wrong.
    – Stephan
    Oct 11, 2018 at 15:50
  • Thank you for you kind people to answer question,now i know that it is a custom made idea use Xming to use X windows system,so it is not cmd,and in the settings it says "bash“ . now I am so confused that Princeton University teacher is so cool
    – Tachikoma9
    Oct 11, 2018 at 16:42

1 Answer 1

1

The output you observed means that you haven't completed the installation of some class-specific programs. The installer for this is mentioned in Section 0 of the link you provided. The most likely cause is that there were some environmental variables that were not modified correctly to add the java-introcs executable or alias to %PATH%. However, you are probably able to replicate the intent of java-introcs, as described below.

To figure out how to make the given Barnsley file compile and run, you'll need to add the dependency StdDraw.class to the classpath when running the file. To do this, you can use the java and javac option -classpath or -cp. You can read more detailed documentation on how to do this here.

2
  • Thank you for your answer. Now I download the version course provide,and it's linux version terminal. But the answer is very helpful for me to figure out how to make it in windows.TY again.
    – Tachikoma9
    Oct 11, 2018 at 16:49
  • If this is for a specific course, I would ask your instructor for the aforementioned StdDraw class/java file. It may be that it is actually inside a .jar file, which is then what you would need to add to your command. Your command to compile would end up looking something like this: javac -classpath ".:/path/to/StdDraw/" Barsley.java, and you would include the same -classpath [...] parameter for java to run it. Oct 11, 2018 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.