How to create a batch file for Java Console Application?

Discussion in 'Java' started by Mozart, Apr 23, 2011.

  1. Mozart

    Mozart Guest

    I have a Java console application.

    It needs to be decompressed and then found
    on the hard drive. One has to keep double clicking until
    one finds the folder that says Resources. In this
    folder there will be a program that says Contents.
    In that folder, ones clicks on the JParaMindAndDictStd.bat
    file and the program launches without any problem.

    I am trying to write a batch file for Windows 7 users
    so they can launch it easily (Windows 64 bit users especially).
    I am also hoping this file will work in other versions of
    Windows such as XP.

    Does anyone have any advice on this? Various methods
    have not worked.

    --
    Robert Pearson
    ParaMind Brainstorming Software http://www.paramind.net
    Telical Books http://www.telicalbooks.com
    Mozart, Apr 23, 2011
    #1
    1. Advertising

  2. Mozart

    Lew Guest

    On 04/23/2011 03:34 PM, Mozart wrote:
    > I have a Java console application.
    >
    > It needs to be decompressed and then found
    > on the hard drive. One has to keep double clicking until
    > one finds the folder that says Resources. In this
    > folder there will be a program that says Contents.
    > In that folder, ones clicks on the JParaMindAndDictStd.bat
    > file and the program launches without any problem.
    >
    > I am trying to write a batch file for Windows 7 users
    > so they can launch it easily (Windows 64 bit users especially).
    > I am also hoping this file will work in other versions of
    > Windows such as XP.
    >
    > Does anyone have any advice on this? Various methods
    > have not worked.


    How to invoke a batch file is a Windows question, not a Java question.

    The key is to provide the full path to the executable in your batch file.

    If you continue to have difficulty, seek out a Windows forum.

    --
    Lew
    Honi soit qui mal y pense.
    http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
    Lew, Apr 23, 2011
    #2
    1. Advertising

  3. Mozart

    Roedy Green Guest

    On Sat, 23 Apr 2011 12:34:47 -0700 (PDT), Mozart
    <> wrote, quoted or indirectly quoted
    someone who said :

    >Does anyone have any advice on this? Various methods
    >have not worked.


    Separate running and installing.

    You might want to use an installer.

    see http://mindprod.com/jgloss/installer.html
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    Politicians complain that Kindles and iBooks are killing jobs by
    destroying the paper book industry. I see it that they have create a way
    to produce books for less than a third the cost without destroying forests
    and emitting greenhouse gases in the process. They have created wealth.
    They are encouraging literacy and cutting the costs of education.
    Roedy Green, Apr 24, 2011
    #3
  4. Mozart

    buddy s Guest

    On Apr 24, 3:34 am, Mozart <> wrote:
    > I have a Java console application.
    >
    > It needs to be decompressed and then found
    > on the hard drive.  One has to keep double clicking until
    > one finds the folder that says Resources.  In this
    > folder there will be a program that says Contents.
    > In that folder, ones clicks on the JParaMindAndDictStd.bat
    > file and the program launches without any problem.
    >
    > I am trying to write a batch file for Windows 7 users
    > so they can launch it easily (Windows 64 bit users especially).
    > I am also hoping this file will work in other versions of
    > Windows such as XP.
    >
    > Does anyone have any advice on this?  Various methods
    > have not worked.
    >
    > --
    > Robert Pearson
    > ParaMind Brainstorming Softwarehttp://www.paramind.net
    > Telical Bookshttp://www.telicalbooks.com



    you need to first set your classpath in .bat file and then your need
    to invoke your application using "java" command you can get more
    information about classpath here http://javarevisited.blogspot.com/2011/01/how-classpath-work-in-java.html
    buddy s, Apr 24, 2011
    #4
  5. Mozart

    Roedy Green Guest

    On Sat, 23 Apr 2011 23:54:38 -0700, Patricia Shanahan <>
    wrote, quoted or indirectly quoted someone who said :

    >
    >Why do you consider setting the classpath variable preferable to using
    >the java -cp parameter?


    if you change the global classpath you could screw up some other Java
    app.
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    Politicians complain that Kindles and iBooks are killing jobs by
    destroying the paper book industry. I see it that they have create a way
    to produce books for less than a third the cost without destroying forests
    and emitting greenhouse gases in the process. They have created wealth.
    They are encouraging literacy and cutting the costs of education.
    Roedy Green, Apr 24, 2011
    #5
  6. Mozart

    Mozart Guest

    On Apr 24, 8:55 am, Peter Duniho <> wrote:
    > On 4/23/11 11:54 PM, Patricia Shanahan wrote:
    >
    > > On 4/23/2011 8:37 PM, buddy s wrote:
    > >> [...]
    > >> you need to first set your classpath in .bat file and then your need
    > >> to invoke your application using "java" command you can get more
    > >> information about classpath here
    > >>http://javarevisited.blogspot.com/2011/01/how-classpath-work-in-java.....

    >
    > > Why do you consider setting the classpath variable preferable to using
    > > the java -cp parameter?

    >
    > Can't answer for "buddy s", but I think -cp is clearly superior.
    >
    > But if someone really wanted to set the CLASSPATH environment variable
    > in a Windows .bat batch file, they can easily do so without affecting
    > other Java programs as long as the batch file itself runs only the one
    > Java program and either a) the batch file itself is run in a non-shared
    > environment (e.g. by double-clicking a link to the batch file itself,
    > which will create a new console window just for that batch file), or b)
    > including the "setlocal" statement at the beginning of the batch file,
    > so that any changes to the environment are not preserved once the batch
    > file ends.
    >
    > Pete


    Thanks for all the feedback.

    OK, maybe I can get a little simpler advice. I do not have that much
    experience in Java programming and I was more active in this project
    on the
    C++ end. I appreciate the technical discussion but it's on a level a
    few levels more abstract than creating a practical solution. The
    average user I find cannot be trusted to know much about anything and
    so install routines need to be brainless. I have had a lot of
    professional
    experience with average end users and their needs. Most of them are
    not technically
    inclined.

    Right not I have a Java console application
    that needs to be decompressed from a zip file. I imagine
    that they can see the folder at this point after they have
    personally decompressed this file.
    I can give them instructions like this:

    "One has to keep double clicking on the folders you see until
    one finds the folder that says Resources. In this
    folder there will be a program that says Contents.
    In that folder, ones clicks on the JParaMindAndDictStd.bat
    file and the program launches without any problem."

    Can someone think of a solution easy for me to program as an essential
    Java newbie that will help a newcomer not have to navigate a lot
    of hidden folders?

    This is the current path structure of the batch file:

    java -cp c:\ParaMind Windows64-1.1\JParaMind.app\Contents\Resources
    \Java\JParaMindAndDict.jar JParaMind

    How could I make the path more of a global variable that would work on
    anyone's machine?
    Mozart, Jun 3, 2011
    #6
  7. Mozart

    Roedy Green Guest

    On Fri, 3 Jun 2011 10:53:41 -0700 (PDT), Mozart
    <> wrote, quoted or indirectly quoted
    someone who said :

    >On Apr 24, 8:55 am, Peter Duniho <> wrote:
    >> On 4/23/11 11:54 PM, Patricia Shanahan wrote:
    >>
    >> > On 4/23/2011 8:37 PM, buddy s wrote:
    >> >> [...]
    >> >> you need to first set your classpath in .bat file and then your need
    >> >> to invoke your application using "java" command you can get more
    >> >> information about classpath here
    >> >>http://javarevisited.blogspot.com/2011/01/how-classpath-work-in-java....

    >>
    >> > Why do you consider setting the classpath variable preferable to using
    >> > the java -cp parameter?

    >>
    >> Can't answer for "buddy s", but I think -cp is clearly superior.
    >>
    >> But if someone really wanted to set the CLASSPATH environment variable
    >> in a Windows .bat batch file, they can easily do so without affecting
    >> other Java programs as long as the batch file itself runs only the one
    >> Java program and either a) the batch file itself is run in a non-shared
    >> environment (e.g. by double-clicking a link to the batch file itself,
    >> which will create a new console window just for that batch file), or b)
    >> including the "setlocal" statement at the beginning of the batch file,
    >> so that any changes to the environment are not preserved once the batch
    >> file ends.
    >>
    >> Pete

    >
    >Thanks for all the feedback.
    >
    >OK, maybe I can get a little simpler advice. I do not have that much
    >experience in Java programming and I was more active in this project
    >on the
    >C++ end. I appreciate the technical discussion but it's on a level a
    >few levels more abstract than creating a practical solution. The
    >average user I find cannot be trusted to know much about anything and
    >so install routines need to be brainless. I have had a lot of
    >professional
    >experience with average end users and their needs. Most of them are
    >not technically
    >inclined.
    >
    >Right not I have a Java console application
    >that needs to be decompressed from a zip file. I imagine
    >that they can see the folder at this point after they have
    >personally decompressed this file.
    >I can give them instructions like this:
    >
    >"One has to keep double clicking on the folders you see until
    >one finds the folder that says Resources. In this
    >folder there will be a program that says Contents.
    >In that folder, ones clicks on the JParaMindAndDictStd.bat
    >file and the program launches without any problem."
    >
    >Can someone think of a solution easy for me to program as an essential
    >Java newbie that will help a newcomer not have to navigate a lot
    >of hidden folders?
    >
    >This is the current path structure of the batch file:
    >
    >java -cp c:\ParaMind Windows64-1.1\JParaMind.app\Contents\Resources
    >\Java\JParaMindAndDict.jar JParaMind
    >
    >How could I make the path more of a global variable that would work on
    >anyone's machine?
    >
    >

    You best bet is to enclose everything in a Jar and leave the classpath
    alone.
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    How long did it take after the car was invented before owners understood
    cars would not work unless you regularly changed the oil and the tires?
    We have gone 33 years and still it is rare to uncover a user who
    understands computers don't work without regular backups.
    Roedy Green, Jun 5, 2011
    #7
  8. Mozart

    Joined:
    Jun 16, 2011
    Messages:
    1
    hi,
    i created web application for upload and download zip files using struts.when i am trying to download that file.file is downloaded successfully.then if i try to open that file using winzip i am getting problem.that is not valid archive?if i try local system its working fine?please give me any suggestion if any one knows?
    , Jun 16, 2011
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raterus
    Replies:
    1
    Views:
    925
    Patrice
    Apr 23, 2004
  2. Cyril Dex
    Replies:
    7
    Views:
    140,851
    sankalp.sawant59
    Mar 10, 2013
  3. Replies:
    3
    Views:
    880
    Andrew Thompson
    Feb 14, 2008
  4. Jim Heavey
    Replies:
    0
    Views:
    250
    Jim Heavey
    Jan 25, 2006
  5. king

    create a batch file

    king, Oct 23, 2007, in forum: Perl Misc
    Replies:
    1
    Views:
    204
    Michele Dondi
    Oct 23, 2007
Loading...

Share This Page