473,387 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do i run jar files from within a java program?

Hi,

I have created several projects using eclipse and java. Each of these projects has a runnable .jar file. I would like to create one java program which would call each of my .jar files, kind of like a batch sequential system where one jar file would execute only after the previous one has completed.

Expand|Select|Wrap|Line Numbers
  1. public static void main(String[] args) {
  2.      call jar file 1
  3.      call jar file 2
  4.      call jar file 3
  5. }
  6.  
  7.  
this way, if i create future projects that need to run after my last jar file, i would simply add a new line:
call jar file 4

I have tried google but the examples there do not seem to be working on my machine. This is what i have tried:

Expand|Select|Wrap|Line Numbers
  1. ProcessBuilder builder = new ProcessBuilder("java -jar A.jar");
  2. Process process = builder.start();
  3.  
when i try to run this, i get an error:
Cannot run program "java -jar A.jar": CreateProcess error=2, The system cannot find the file specified


i have googled this error and this error refers to the environment path. I have verified this and my environment path points to the right location.

any ideas?

this is what's in my Environment Path:
C:\Program Files\Java\jdk1.6.0_25\jre\bin\;C:\Program Files\Java\jre6\bin\;C:\Program Files (x86)\SSH Secure Shell;

and this is whats in my class path:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\Sy stem32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShel l\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Java\jdk1.6.0_25\jre\bin\;C:\Program Files\Java\jre6\bin\;C:\Program Files\TortoiseSVN\bin;

thank you!
Aug 9 '11 #1
1 6896
Dheeraj Joshi
1,123 Expert 1GB
A.jar should reside in current class location or it should be mentioned in the environment variables.

Regards
Dheeraj Joshi
Aug 16 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: enclume42 | last post by:
Hello, I am a pure Linux guy. I wrote a Java program that is going to be used by some Windows people, and I wish the startup of the program to be as simple as possible, namely to double-click on...
5
by: Tyler | last post by:
Hi ppl, I know it's forbidden to mention Java in this newsgroup but I've been presented with a problem which requires that my C++ program communicate with another java program. What is the...
1
by: snicks | last post by:
I have a series of XLS files which I need to embed into a PowerPoint presentation on an IIS server. I’ll be using VB.NET. I’ve tried using an ASPOSE.PowerPoint control to do this and it does...
1
by: =?Utf-8?B?S2Vubnk=?= | last post by:
I have one bat file that contains a command to startup Java Program. Then, I would like to create a cluster job to call the bat file. In case of one computer is down, another computer can also call...
16
by: Knute Johnson | last post by:
I'm trying to write a C wrapper to run a Java program. I need to distribute a CD with the Java runtime, my application and a C startup program. I've put the C wrapper program, my java app and the...
3
by: hostel | last post by:
Hi, i set the classpath what ever required and my java program is running fine . i have installed jdk in C:\ , am saving my files in D:\ while compling in command prompt i have to go...
4
by: Quill_Patricia | last post by:
I have a Python script which is used to load data into a database. Up to now this script has been run by customers from the Windows command prompt using "python edg_loader.pyc". Any error messages...
10
Nepomuk
by: Nepomuk | last post by:
Hi there! I'm trying to create a XML file from within Java. After doing a bit of research, I'm quite confused - there seem to be many, many classes in the standard libraries (plus many more...
0
by: Siyodia | last post by:
This is a java program which i need to run facing compilation error Its consuming a third party web service method I have the supported files(folder) which contain necessary class files...
3
by: vamsirays | last post by:
i have created some database in microsoft access, during execution of java program error came like this, Access restriction: The constructor JdbcOdbcDriver() is not accessible due to restriction...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.