• 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

import jar, many files, no main, -d command line

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Here's my code:

in file A:



... new file (B):






three of them all, with the *.jar, in one basic folder; I can compile while using the -cp, but then, import jar doesn't follow..

I can't have it working while using -d...

Thanks for your help
 
Saloon Keeper
Posts: 15524
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

JARs are not "imported".

Please show us the commands you used to build AND run that worked, and then show us the commands you used to build AND run that didn't work.
 
Helene Renaud
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here,


Then, I corrected it to work as per the example I had:

I added the line to import 'util.*', and the word 'static', on the import jar, as per this code:



Compile this way works fine:
  javac -cp net.mindview.util.jar;. Helloworld.java
   and run as per:
   java -cp net.mindview.util.jar;. Helloworld

If I change -cp for -d; I get an error...
(net.mindview.util.jar;. not found) as you said...

I wrote the same cmd for A and B classes

compile: javac -cp net.mindview.util.jar;. A.java B.java
run :     java -cp net.mindview.util.jar;. A

          Couldn't find or load main class p1.A
           (of course)

and if I rather write
          java A
          ... couldn't load or find main class A

So, at compile, there is no error but in fact, it doesn't create directory structure...
Is there any ways to trick it? Like compiling the all pack in jar, then unjar with -d?


Thanks again for your answers to come.


Helene





 
Stephan van Hulst
Saloon Keeper
Posts: 15524
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you are confused about what the -d switch does.

Can you explain in your words what you think it does? What do you want it to do?
 
I like tacos! And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic