0

I want to compile my Java program in command line. Until now, NetBeans have been doing this job for me.

My program consists of:

/program/
        /src/mypacket/
                     /klass1.java
                     /...
        /src/Main.java
        /resources/
                  /img1.png
                  /...
        /lib/
            /jar1.jar
            /...

Unfortunately, I am not able to build a proper command. My efforts resulted in sth like:

javac -classpath lib/*.jar src/mypacket/*.java src/Main.java

In result I get ~20 errors similar to:

src/mypacket/myclass.java:4: error: The import xyz.zyx cannot be resolved

What do I do wrong?

1
  • all imports are from lib? aren't there libraries referenced indirectly from lib jars that you need to provide in classpath? Commented Jun 6, 2013 at 20:16

1 Answer 1

3

Classpath should be lib/one.jar:lib/two.jar but your shell expands it to lib/one.jar lib/two.jar.

Sign up to request clarification or add additional context in comments.

2 Comments

I assumed that you are using Linux, Unix or MacOs because of using slash and *. If it is not true, shout.
dir/*.ext works in Windows too, since at least Windows XP. You should probably note in your answer that the path separator char in Windows is ;.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.