Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Help using this Jar File (newbie)

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Help using this Jar File (newbie)

    i have a simple .jar file i want to use but have no idea HOW to get this thing to run. it is based on this website (see below) It is a simple Sentence Segementer (splits paragraphs of text files into 1 sentence per line).

    I am attaching the .jar as a .zip as well, im just not sure how java works. I have java installed and verified, i tried using several commands from CMD but nothing works for me...

    I understand that I need a txt file but how to execute and what are the commands is my main problem. Do i need a 3rd party SW, do i need to create a GUI?

    thanks you!!

    here is the with insight as well file attached
    Attached Files Attached Files


  2. #2
    Forum VIP
    Join Date
    Jun 2011
    Posts
    317
    My Mood
    Bored
    Thanks
    47
    Thanked 89 Times in 74 Posts
    Blog Entries
    4

    Default Re: Help using this Jar File (newbie)

    .jar file are actually .zip files so there is no need to zip them up.

    You can run this from the command line with

    java -jar sptoolkit.jar

    If java is set up correctly it will give you an error telling you the proper usage:
    Command-line usage: cat input_text | Java -jar sptoollit.jar -f [1234]

    If you are using linux this should be pretty straight forward. On windows the equiviliant for 'cat' is 'type'. You will also want to pipe the output to a new file so the command would be:

    type input.txt | java -jar sptoolkit.jar -f 1 > output.txt

  3. The Following User Says Thank You to ChristopherLowe For This Useful Post:

    ilcaa (January 8th, 2014)

  4. #3
    Junior Member
    Join Date
    Jan 2014
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Help using this Jar File (newbie)

    thanks Chris, that was perfect. Exactly what I needed to understand these files...

    My next step is to try to automate this process a little more... Instead of using the command prompt to run this java script I was thinking maybe right clicking a .TXT file, then selecting a command that executes the java that uses the selected .TXT as the input and automatically creates the output .TXT in the same directory.

    Is this too involved to accomplish? Whats your professional opinion ?

    thanks again for your help!

  5. #4
    Forum VIP
    Join Date
    Jun 2011
    Posts
    317
    My Mood
    Bored
    Thanks
    47
    Thanked 89 Times in 74 Posts
    Blog Entries
    4

    Default Re: Help using this Jar File (newbie)

    Thats a more complicated problem. You will need to create a .bat file that:
    • accepts a .txt file as an input parameter
    • creates an appropriate name for the output
    • executes the above command


    You will then put this somewhere on the system environment's PATH. The idea is to condense the above command into something you can run anywhere from the command line with;
    sptoolkit.bat inputfile.txt

    At this stage you can look at adding this batch file to the right click context menu by editing the registry. There are some instructions on SuperUser

  6. #5
    Junior Member
    Join Date
    Jan 2014
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Help using this Jar File (newbie)

    Quick question regarding running this command line...

    what is the rule as far as referencing the file.
    Do I need to change the dir in cmd to reflect the location where the file is located? or
    Does the location need to be part of the command line?
    does the file i use as the input need to be in the same folder as the java file?
    do i need to add a full location reference to the input file in the cmd line?

    having trouble understanding the specific rule for this..

  7. #6
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Help using this Jar File (newbie)

    You should be able to answer your own questions with simple experimentation. Write your .bat file and test it. There's no "rule," other than doing what works, and there are multiple ways to write code that "works".

Similar Threads

  1. run jar file inside a jar file?
    By ufrubnuckle in forum Java Theory & Questions
    Replies: 1
    Last Post: February 21st, 2013, 06:58 AM
  2. Run a jar file inside a batch file with Windows 7 Task schduler
    By kingnachi in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 15th, 2012, 09:20 AM
  3. [SOLVED] jar file Built(clean and build) perfectly, but not running as jar
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 18
    Last Post: July 11th, 2011, 11:41 AM
  4. Replies: 10
    Last Post: January 12th, 2011, 05:48 AM
  5. Replies: 5
    Last Post: November 13th, 2010, 01:53 PM