Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2008
    Posts
    2
    Rep Power
    0

    Default Is there any way to run java file through command prompt of .jar

    Hi *,

    I have created a jar and deployed in server which runs fine :)

    now i want to keep a java file in it with public static void main functionality, which i want to run through command prompt after some time or when ever i want is it possible to do so?


    Thanks and Regards,
    Sachin Parnami

  2. #2
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    10

    Default

    Show us the code,if understood you correctly,then you do that with arguments

  3. #3
    Join Date
    Dec 2008
    Posts
    2
    Rep Power
    0

    Default

    import java.util.Date;


    import org.quartz.CronTrigger;
    import org.quartz.JobDetail;
    import org.quartz.Scheduler;

    public class QuartzRunImpl extends QuartzSchedulerImpl{

    String jobName = "job1";
    String groupName = "group1";

    public QuartzRunImpl() {
    super();
    }
    public static String entityName;



    public void run() throws Exception {

    try {
    Scheduler scheduler = (Scheduler) getScheduler();
    JobDetail jobDetail = (JobDetail) getJobDetail();
    jobDetail.setName(entityName);
    jobDetail.setGroup(groupName);
    jobDetail.setJobClass(QuartzResourceAdaptor.class) ;
    Date temp = getTime();
    // will trigger job in every 20 seconds
    CronTrigger cronTrigger = (CronTrigger) getCronTrigger("jobName",
    "jobGroup", entityName, groupName, "0/20 * * * * ?");
    // SimpleTrigger trigger = (SimpleTrigger) getSimpleTrigger(jobName,
    // groupName , temp);
    scheduler.addJob(jobDetail, true);
    scheduler.scheduleJob(cronTrigger);
    scheduler.start();
    Thread.sleep(90L * 1000L);
    scheduler.shutdown(true);
    } catch (Exception e) {
    System.out.println("##### EXCEPTION AT QUARTZ RUN ######" + e);
    }
    }
    public static void main(String args[]) throws Exception{
    QuartzRunImpl quartzRun= new QuartzRunImpl();
    quartzRun.run();
    System.out.println("########################## -----------QuartzRun---------###########################");

    }
    }


    thats the file which is being deployed with other java files in JAR which is not being used untill explicitlly invoked :)

    here is the jar details
    META_INF
    xyz.class
    abc.class
    zzz.class

Similar Threads

  1. how to run windows command prompt in java parogram ?
    By indikasampath2000 in forum AWT / Swing
    Replies: 4
    Last Post: 12-16-2008, 07:51 AM
  2. help me!!!! about command prompt..
    By kureikougaiji in forum New To Java
    Replies: 2
    Last Post: 11-13-2008, 07:15 PM
  3. Running eclipse java project on command prompt
    By hnmapara in forum New To Java
    Replies: 1
    Last Post: 07-09-2008, 09:29 AM
  4. accessing command prompt using java (netbeans)...
    By kureikougaiji in forum New To Java
    Replies: 6
    Last Post: 06-27-2008, 04:01 PM
  5. Problem during executing Command Prompt
    By keshari in forum Advanced Java
    Replies: 4
    Last Post: 06-05-2008, 05:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •