• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

extension mechanism and javac

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

I'm having a problem with the use of the extension mechanism and javac. I've got these directories: C:\Test\upperpackage\subpackage and C:\Libraries. In subpackage I have the class HelloWorld:

In C:\Libraries I've got testjar.jar, which contains MessageGenerator.class and Manifest.mf. This is class MessageGenerator:

I've "jared" testjar.jar with this line in test.txt:

Having test.txt and MessageGenerator.class in C:\Libraries I used this command:

Then trying to compile HelloWorld this came up:

What have I been doing wrong?
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Having test.txt and MessageGenerator.class in C:\Libraries is wrong, since you say, that MessageGenerator is in "upperpackage".

"import upperpackage.MessageGenerator;"

compile via javac from "C:\Test\"


Another pitfall might be:

I've "jared" testjar.jar with this line in test.txt:
Class: upperpackage/MessageGenerator.class [CR]


Try
 
Peter Merker
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Stefan Wagner:
Having test.txt and MessageGenerator.class in C:\Libraries is wrong, since you say, that MessageGenerator is in "upperpackage".


Well, I'm not having test.txt and MessageGenerator.class in C:\Libraries. There is only the jar which contains MessageGenerator.class and Manifest.mf. I also tried adding another line to the Manifest file, now having

but this didn't change things either. I disagree that MessageGenerator.class should be in upperpackage, this is certainly possible, but not what I want. I want to learn how to use a jar together with a "simple" java file.


compile via javac from "C:\Test\"


This only works if MessageGenerator.class is in upperpackage (and C:\Test is in the classpath, of course). But, like I said, that's not the way I want it to be.


Another pitfall might be:


I thought that attribute Main-Class would indicate the class with the main method in a jar. As the main method in my example is in HelloWorld, this shouldn't be used, or?
[ June 06, 2005: Message edited by: Peter Merker ]
 
Stefan Wagner
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



but this didn't change things either. I disagree that MessageGenerator.class should be in upperpackage, this is certainly possible, but not what I want. I want to learn how to use a jar together with a "simple" java file.


I thought that attribute Main-Class would indicate the class with the main method in a jar. As the main method in my example is in HelloWorld, this shouldn't be used, or?


a) Your code contains:
import upperpackage.MessageGenerator;
so either you change that, or MessageGenerator has to be in upperpackage.
It's not a question of taste, but of function.

b) You're right, it shall contain the class containing 'main', that was my error.
I only wanted to point out, that the name of the tag is 'Main-Class:', not 'Class:'.

[ June 06, 2005: Message edited by: Stefan Wagner ]
[ June 06, 2005: Message edited by: Stefan Wagner ]
[ June 06, 2005: Message edited by: Stefan Wagner ]
 
Peter Merker
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I finally found my error. It was quite stupid. When I jarred I didn't have the directory structure in the jar, that was right, Stefan. So now I invoked

having test.txt in C:\Test and MessageGenerator.class in C:\Test\upperpackage. I kept the "Class:" tag in test.txt as it is a valid tag, just as Main-Class. So now I got:

Running it:

Thank you Stefan, you pointed me in the right direction!
[ June 07, 2005: Message edited by: Peter Merker ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic