Solved

Batch file creation

Posted on 2011-02-22
8
290 Views
Last Modified: 2012-05-11
Hello,

I'm trying to create a batch file based on a JAVA Eclipse project I have running.

I've created a text file (test.bat)

I have a number of inputs in my run configuration.  

Program Arguments:
Path to input folder - C:/Eclipse/Workspace/ProjectName/Input

VM Arguments:
-DlogFile_var=C:/temp

Unsure of how to set it up.  Are there any good references you could point me towards?

Calling the main class etc.

I'll be providing the app in a zip file that the user will extract to their computer.  The user will update the batch file with the path to the input folder and other settings.
Thanks
0
Comment
Question by:AndyC1000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
8 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 334 total points
ID: 34949606

At the bottom of this thread there is the simplest example:
http://www.velocityreviews.com/forums/t127584-how-to-create-a-batch-file-to-run-a-java-application.html

If you want something more sophisticated you can go for installer programs and packages, some are commerically available of course
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34950038
If you really want to install big appliactions then you could go for special tools
like InstallAnywhere or InstallShield, but if you are deploying for limited number of people
within your company then batch file is quite fine.

As I mostly write programs for folks within one site of one company, I prefer to put application classes to a folder on the fileshare,
create batch file also on that share and then  each client just needs to have shortcut to that batch
file on his/her desktop. I am even using Java virtual machine from the same fileshare - it does take
longer time to launch, but the great benefit is that I'm not dependent on their individual VMs.
I'm sure no experts will recommend you this way, but it works for me and for dozens of my clients
for about 10 years with minimum disruptions and pain. And when I need to upgrade, I just change the code
in one place. Of course if your users are in different places and sites and they are very numerous - then it is another story.

 
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 166 total points
ID: 34950280
You would be better off exporting the project to an executable jar

http://www.associatedcontent.com/article/2888442/using_eclipse_export_option_to_build.html?cat=15
0
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 

Author Comment

by:AndyC1000
ID: 34967958
This is the batch file I've created.  Not sure where the issue is, any ideas?  It's not the running app.  

@ECHO OFF
ECHO STARTED Batch..

if not "%JAVA_HOME%" == "" goto javaHomeAlreadySet
for %%P in (%PATH%) do if exist %%P\java.exe set JAVA_HOME=%%P..\
:javaHomeAlreadySet


:: Directory and file locations
SET args[0]= data/post/input/State :: Program arguments

SET -DprocessAll=true  :: VM argument
SET -DprocessEns=true ::VM argument
SET -DmissingVal="-1" ::VM argument
SET -DlogFile_var=C:/temp ::VM argument

:: Date for log file (not currently used)
FOR /F "tokens=*" %%A IN ('DATE/T') DO FOR %%B IN (%%A) DO SET Today=%%B
FOR /F "tokens=5 delims= " %%A in ('echo ^| time ^| find "current" ') DO FOR %%B IN (%%A) DO SET Now=%%B
FOR /F "tokens=1-3 delims=/-" %%A IN ("%Today%") DO (
    SET Day=%%A
    SET Month=%%B
    SET Year=%%C
)
FOR /F "tokens=1-3 delims=:.-" %%A IN ("%Now%") DO (
    SET Hour=%%A
    SET Min=%%B
    SET Sec=%%C
)

:: Read and convert output
ECHO STARTING 

:: How to run program here-->
java -cp /src/csi/cl/da/post/WSAdaptor.java

ECHO FINISHED READING and converting output

:END
ECHO ...End Batch
@ECHO ON

Open in new window




0
 
LVL 47

Expert Comment

by:for_yan
ID: 34967967
in the run command after -cp you should have the classpath argument, the calss stating excutin
(with main method) should be separate arguument
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34967976
Something like that:
java -cp (here your classpath without spacses enumartion of jar failes usually)    (here space)  com.mypackage.MyMainClassName
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 334 total points
ID: 34967987



This is real life example:


java   -classpath "d:\jdk1.4.1_02\lib\tools.jar;..\bin\bootstrap.jar "     org.apache.catalina.startup.Bootstrap start
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34967991
In the example above after -classpath you see a buch of jars, then after space your main calss ij this case
org.apache.catalina.startup.Bootstrap  and the argument for that class (in this case start)
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question