Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8658983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:53:46+00:00 2026-06-12T15:53:46+00:00

I am facing a problem in running a jar file from my servlet. I

  • 0

I am facing a problem in running a jar file from my servlet.
I have to run a jar file of another java application with arguments in a separate sevlet in web project in Eclipse.

I use the code as

Runtime.getRuntime().exec("java -jar myproject.jar param1 param2 abc.xml");

In above code, on running the above jar file with parameters param1 and param2 , it will store output in abc.xml.
But the problem is that i dont know how to give the path of myproject.jar in code.

I copied myproject.jar to the project directory and it does not give any output.
I have tried to use
I dont know how to give path of jar file and where to put the jar file and where the out put file will come .

This code works fine with simple core java application where i put my myproject.jar file in the core java project directory and the output file abc.xml is created in the core java project directory.

Please guide me.
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:53:47+00:00Added an answer on June 12, 2026 at 3:53 pm

    This is not the right way of invoking Java code contained in some JAR in the classpath (I assume that you have placed it in /WEB-INF/lib). Just import and invoke the code contained in that JAR file directly.

    import com.packagefromjar.SomeMainClassInJar;
    
    // ...
    
    SomeMainClassInJar.main(new String[] { "param1", "param2", "/path/to/abc.xml" });
    

    Or if that API is well designed, then just use its entry classes directly instead of calling a main() method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am facing a strange problem while running my application. I have a class
I am facing problem to get variable from query string. I have used htaccess
I have AMQ + Activemessaging running in a Rails App. I'm facing a problem
I'm facing a problem when running the AdHoc distribution app, I've developed an application
I am facing problem in accessing database file when I am running it on
I am facing one strange problem, when i run my android application on the
I'm facing a very weird kind of problem while running my application. When I
I have been facing this problem for quite sometime now. Running 'adb devices' shows
I am facing problem with the control flajaxian.FileUploader i.e. after downloading the dll file
I am facing this problem while installing extensions, themes basically anything from magento connect.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.