Win a copy of The Career Toolkit this week in the Jobs Discussion forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Using a class from a Jar File

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was working through the excercises in this website's cattle drive section but then I got to one where it said I have to dowload a jar file and use a class in there. So I found out how to extract files from a jar file using the -xf command, but I feel like I am missing something. Am I supposed to just extaract the files, find the class files I need, and put it in the same folder as the program I'm writing? Or is there a better way? I tried using a package statment, because all the class files are in a series of folders com/javaranch/common but it doesn't seem to be working.
 
Ranch Hand
Posts: 33
VI Editor Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, Benjamin.

When you are asked to use a class from a jar file, they want you to do the following:
  • download the jar file
  • add the jar to your classpath
  • use an import statement for the class


  • check the -classpath option of both the javac and the java command
  • javac command
  • java command


  • For how to use import statement, see the following :
  • import statements
  •  
    Benjamin Thvedt
    Ranch Hand
    Posts: 31
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Ah. Thanks a lot!
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic