Menu

accessing the library from comman line

dave
2007-05-01
2013-04-22
  • dave

    dave - 2007-05-01

    hi there,

    I am very much a noob with java.

    I don't want to hit myself with any gui apps just yet as i understand concepts of OOP but when it comes to putting it into action i hit a brick wall :)

    thus i'm starting with the console first and have d/l ver 3.0.

    I am wanting to fin out how you make calls from a console program (ie NON GUI APP).

    cheers,

    dave.

     
    • Paul Zepernick

      Paul Zepernick - 2007-05-01

      Hi Dave,

      Are you trying to figure out how to run the examples, or how to create a program to run from the command line in general?

      Here is how you get a java class to run from command line:

      java -cp ./ MyClassToRun

      You must be in the same dir as the java class or modify the -cp (Class Path) appropriately. The above example sets the class path to the current directory.

      The class you are running must have a main method declared.  This is the entry point for the program:

      public static void main(String[] args) {

      }

      Thanks,

      Paul

       
      • dave

        dave - 2007-05-02

        hi paul,

        i'm using a text editor and cmd line to compile (got netbeans ide and eclipes but can't after an hour or more of playing find how to compile and write code without using GUI libraries.

        then found that with exciples from a form message somewhere where you can't write console apps due to eciples using ant. true or false i dunno but couldn't find anything in either ide to achieve my goal ( ie using an ide for help and hints on syntax and coding for the console).

        so ...

        for me to use the library i d/l'd i'd do this

        import java.io.*
        import java.utils.*
        import com.PZFile.*

        or am i way off base ??

        do you have samples of code (within the package i got) from the cmd line (be it from linux or windows)??

        cheers,

        dave.
        dave

         
    • Paul Zepernick

      Paul Zepernick - 2007-05-03

      Hi Dave,

      There are some examples if you download the source to the project. Once you unzip the examples can be found in the following directory:

      \PZFileReaderSamples\src\main\java\net\sf\pzfilereader\examples

      The package structure for the classes in the project is "net.sf.pzfilereader.*" instead of "com.PZFile.*"

      I use eclipse for all my development.  You can right click and do a new project and then select java project.  Once in the project right click and do new class.  You can also right click and go to the properties for a project.  There should be a tab for "classpath" where you can add jars to the project that you are going to be utilizing.  To run the class you should be able to right click the java file and go to run as --> java application.

      Regards,

      Paul

       

Log in to post a comment.

MongoDB Logo MongoDB