Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compiling 2 classes

 
Robert Darling
Ranch Hand
Posts: 100
Android Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a question from the KB book "CHAPTER 10 DEPLOYMENT"
The first class is GetJar


The second class is Foo


The question asks that given a directory structure as below, how would you compile both classes

test -
    | GetJar.java
    | -MyAPP|
            |Foo.java

Suppose that we are in the test folder.
How would we compile both file.

to compile Foo.java we would cd to the test folder and


How would we compile the GetJar.java. Since its in a different package. The solution given in the book says

javac MyApp/Foo.java
//Place into test a jar file that contains MyApp/Foo.class
javac -classpath MyJar.jar GetJar.java
java GetJar


But its not working. It does work if i remove the package statement from the Foo class. In the GetJar.java file Foo.d is accessed without importing the MyApp package. Is the question correct. I have tried to replicate the question as closely as possible.

Kind Regards
 
Javier Cortes
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe class GetJar is missing an import:
 
Moguluri Ravi Kiran
Ranch Hand
Posts: 63
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
XXX\test>javac -cp=.;.\MyApp; GetJar.java Foo.java

 
Mark Moge
Ranch Hand
Posts: 100
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the record:
- there is no problem with any package statement
- there is a mistake in the book and the A answer should be (Unix)

if you want to try it on a Windows

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic