简体   繁体   中英

How do I get classes from my course to work with my program?

I'm trying to go through the course/textbook described at the link below, which uses the libraries at the link below. I am trying to write a little test program, which uses the stdout.java and stdin.java libraries.

I am using the windows terminal window with the java development kit .

So i have a program, test.java , which calls stdin.java .

I have test.java , stdin.java and stdout.java in the same directory. I type in javac stout.java and I get no error messages, but when I type in javac stdin.java I get

error: cannot find symbol StdOut.println();

and If I haven't turned stdin.java into a class file (using javac stdin.java) I can run test.java

Stdlib

The problem is that your complied StdOut class is not in the class path . There are a couple of ways you can resolved this.

  1. Add the directory where your complied classes are to your class path.
  2. When you compile, specify the class path using the -cp option.

So for example, you could run the following to compile StdOut and then compile StdIn (assuming you class files are all in the same directory):

javac StdOut.java
javac -cp * StdIn.java

Here is more information on Setting the class path

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM