How to run 1 or more main classes in a jar?

Hi there,
I have 2 or more main classes in a java project. How do I create more than one application entry point in my MANIFEST.INF? I create my jar file from my java project using Eclipse, and it asked me to "Select the class of the application entry point". I was only able to select one main class.
I noticed the MANIFEST.INF file that eclipse generated looks like:
Manifest-Version: 1.0
Main-Class: Automobile
When I tried to run my other classes not specify in the MANIFEST.INF it failed and only look for the Automobile class:
java -jar /tmp/Auto.jar TestMe

Your app. can have as many entry points as you like, as atmguy demonstrated. But you can only specify one in the manifest,which - if you think about it - makes perfect sense. How is the machine to determine - from you clicking on the jar - which entry point you meant to invoke?

Similar Messages

  • How can ı run my JavaMail main class in dos mode ?

    I develop a program about current account. There are two classes. One class is main class. I can run main class in Sun One Studio but ı can not run in DOS mode. If ı wrote "java Carihesap " on command line appear exception in thread main javax/mail/messaging exception.
    Please help me about this problem

    ı didnt include any jars within my project. My project occur only two classes. First one main class other one table model class .

  • How to Invoke a main class in a jar file from my project

    Hi
    I am a new user of the Sun Java Studio enterprise. I would like to know how i can invoke a main method in a jar file associated to the project.
    regards
    Nisanth

    Could you please clarify: do you want to run your project or a project from an independent jar?
    In the first case just select Run Project from the project context menu or select a class with main method and click Run File in the class context menu.
    Regarding the second case:
    - I don't think there is such a feature in the IDE (running third party jars is not an IDE function). Could you explain why you need this?

  • Could not find the main class (with every jar)

    This isn't a developer question. I get the error Could not find the main class with every jar I try to open (for example the jar downloaded from https://gjar.dev.java.net/ gives the same problems - and I don't think there is something wrong with that JAR). It isn't a problem with the jar or MANIFEST because the same jar works fine on my laptop. So there is something wrong with my JRE installation, but what?
    I tried to remove and reinstall the JRE 6 Update 18 but that didn't work. When I run the JAR with command line java -jar "file.jar" it works fine, but if I dubbelclick on it I get the error message (and it's irritating me).
    I'm a bit desperate so I hope that someone here can help me ;)
    Thanks in advanced

    hai T.B.M ... Sorry to post here... I know that i posted my question in wrong thread..but i dont have another solution to contact with you.. I had seen your answers which are really excellent and helped to do my project..
    Now i am having very less time to complete my project and i am very new to JMF.. I am not getting output in JMF video capture ..please check the code and guide me where i gone wrong.......please pardon me once again to post here.. Heres my code
    import javax.media.*;
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    import java.awt.event.*;
    import javax.media.protocol.*;
    import java.io.*;
    import javax.media.control.StreamWriterControl;
    public class webcam implements ActionListener,ControllerListener
    boolean eomReached = false;
    boolean realized = false;
    JFrame f;
    BorderLayout bd1;
    CaptureDeviceInfo device;
    MediaLocator m1;
    Player player;
    Component videoScreen;
    JButton b1,b2;
    Processor processor;
    DataSource ds=null;
    DataSink fileWriter=null;
    JLabel status=new JLabel("");
    public webcam()
    try
    JFrame f=new JFrame();
    JPanel p =new JPanel();
    JPanel p1=new JPanel();
    device=CaptureDeviceManager.getDevice("vfw:Microsoft WDM Image Capture (Win32):0");
    m1=device.getLocator();
    System.out.println("1");
    processor.configure();
    processor = Manager.createProcessor(m1);
    processor.setContentDescriptor(new
    FileTypeDescriptor(FileTypeDescriptor.MSVIDEO));
    ds=processor.getDataOutput();
    player.addControllerListener(this);
    MediaLocator dest = new MediaLocator("file://foo.avi");
    fileWriter = Manager.createDataSink(ds, dest);
    fileWriter.open();
    ds.connect();
    ds.start();
    player=Manager.createPlayer(m1);
    player.addControllerListener(this);
    blockingRealize();
    videoScreen=player.getVisualComponent();
    b1=new JButton("START");
    b2=new JButton("STOP");
    bd1=new BorderLayout();
    p.setLayout(bd1);
    p1.add(b1);
    p1.add(b2);
    p.add("South",p1);
    p.add("East",videoScreen);
    f.getContentPane().add(p);
    f.setVisible(true);
    f.setSize(500,500);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    b1.addActionListener(this);
    b2.addActionListener(this);
    catch(Exception e){}
    public void actionPerformed(ActionEvent e)
    if(e.getSource()==b1)
    try{
    processor.start();
    player.start();
    fileWriter.start();
    catch(Exception e1){}
    if(e.getSource()==b2)
    try{
    player.stop();
    processor.stop();
    processor.close();
    fileWriter.close();
    catch(Exception e2){}
    public static void main(String args[])
    webcam obj=new webcam();
    public synchronized void blockingRealize() {
    player.realize();
    while (!realized) {
    try {
    wait();
    } catch (java.lang.InterruptedException e) {
    status.setText("Interrupted while waiting on realize...exiting.");
    System.exit(1);
    public synchronized void controllerUpdate (ControllerEvent event) {
    System.out.println("myPlayer generated "+event.toString());
    if (event instanceof RealizeCompleteEvent) {
    realized = true;
    notify();
    } else if (event instanceof EndOfMediaEvent) {
    eomReached = true;
    }

  • Don't know how to make my main class import a jar file

    OK, the title doesn't make much sense but here are my create-jar.bat and manifest files:
    create-jar.bat:
    jar cvmf manifest.txt dassimul-admin.jar player/ admin/ com/ connector/ common/ *.class
    manifest.txt:
    Main-Class: admin.DASAdmin
    the problem is that in connector/ folder there is the jdbc mysql connector driver (.jar file).
    in Eclipse I can add this jar to the Java Build Path, so the program runs.
    When I double-click the dassimul-admin.jar file, I get a Class Not Found Exception
    C:\MYWORK\dassimul>java -jar dassimul-admin.jar
    FATAL ERROR WHILE LOADING SQL DRIVER: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    I think that the problem lies in the fact that admin.DASAdmin can't see and import the jar file in connector/ folder... am I right?

    It looks like you are putting the mysql jar file inside the dassimul jar. That won't work unless you write custom code. You should use the Class-Path attribute of the manifest to define a relative path(s) to the other jar(s) that you need to use.
    [http://java.sun.com/docs/books/tutorial/deployment/jar/index.html]

  • How to manage over 200 main classes effectively?

    Where can I found some experience about a big System?
    What's a main class looks alike?
    I got a GUI--subGui--sub-subGUI----...
    and configuration--subconfiguration--subsubconfiguraiton...
    and others.
    How do I connect them together?

    The first thing to do is look at whether or not you actually need the 200+ classes ? Don't worry of the answer is yes. See if you cut down on the number of classes - there may already be standard classes available.
    That should leave you a smaller number of classes. The short answer to your questions is packages. Group the classes into several chunks of logical component or layers. There should be commonalities between the different views and configurations which lend towards a logical partitioning.
    You may want to look at the Struts architecture for guides towards a cohesive web-tier design. Although targeted towards the JSP-Servlet technologies, the Model-View-Controller paradigm applies to the your GUI app.

  • How to run the imported java class in form

    Help!!!!!
    Pls help me to run the imported java class in forms.
    Package is created in forms while imported one class called
    singlexml.class and that package has one procedure and one
    function.
    I just wanted to run that class.I mean the new package.
    Thanks
    Anil

    Hi,
    It is because the converter works on byte code and it only supports a subset of the Java language (see the JC specifications). It is kind of like compiling you code on Java 6 and trying to run it on Java 5. The JCDK outlines the required compiler version.
    Cheers,
    Shane

  • JRE doesn't find the main class inside a JAR archive file

    Hello everybody,
    I've written a small application in Java, using NetBeans. Running my application inside NetBeans works fine, but I can't run it from the console or by double clicking the jar file.
    Running it from the console I get the following error message:
    java -jar TestApplication.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: tst.Benchmark
       at gnu.java.lang.MainThread.run(libgcj.so.81)
    Caused by: java.lang.ClassNotFoundException: tst.Benchmark not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:TestApplication.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
       at java.net.URLClassLoader.findClass(libgcj.so.81)
       at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.81)
       at java.lang.ClassLoader.loadClass(libgcj.so.81)
       at java.lang.ClassLoader.loadClass(libgcj.so.81)
       at gnu.java.lang.MainThread.run(libgcj.so.81)I know that these errors often come when the class path is not set in the right way, and using a single java file, you can fix this by passing the parameter "-cp ."
    I tried this with the jar file but it does not work and using "-cp TestApplication.jar tst/Benchmark" didn't work either.
    Inside the jar file I have the META-INF Folder and a "tst" Folder which contains all my class files. And I've set tst.Benchmark as the main class, this also stands in the manifest file correctly.
    Do you have any ideas what could be wrong?
    Greetings JavanianGuy

    This line
    at gnu.java.lang.MainThread.run(libgcj.so.81)says that you're using GNU's Java, not Sun's Java. They are not the same. GNU Java is incomplete.
    You'll need to ask this question at the GNU Java site.
    Recommendation: Use Sun's Java

  • Main class in a Jar File

    Hi
    I have created a ja file containing my whole project.
    the jar file contains a java class which contains a main method.
    now i want to run this java class present in my jar file from the command prompt. is it possible to do it. can we run a java file which is inside the jar file.
    i don't want to extract the jar file to run the java class.
    Please let me know what needs to be done in this case.
    Thanks & Regards
    Vikeng

    now i want to run this java class present in my jar
    file from the command prompt. is it possible to do
    it. can we run a java file which is inside the jar
    file.
    java -jar MyJar.jarYou need to set the Main-Class attribute in the manifest, though.

  • How to run a compiled file that needs a jar

    Hi all
    I'm trying to run a file that I've compiled that requires a jar
    I have both the jar and java file in the same directory
    HelloWorld.java
    itext.jar
    i compile using
    javac -cp itext.jar HelloWorld.java
    which produces my HelloWorld.class
    but when i run
    java HelloWorld
    I get loads of errors
    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorl
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Sourc
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    am i doing something wrong with trying to run the class with the jar file?

    Didnt work
    C:\Projects\pdf>java -cp .;itext.jar HelloWorld
    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld (wrong name: com/lowagie/examples/general/HelloWorld)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

  • Could not find Main Class while executing JAR

    Hello all,
    I am having a simple Jar file that contains one java class that merely displays a window. I am using NetBeans IDE to create the JAR file. When i execute this JAR file by double clicking on the file, it works fine on the machine. However, if i try to execute this same file on any other windows computer, it gives an error "Could not find the main class. Program will exit."
    In other words, the JAR file is only working on the computer that has NetBeans and JDK installed on. Not on any other machine. Although the other machines have the JAVA Virtual Machine installed.
    I would appreciated any help on this topic.

    I had the same problem (i.e. Message-Box with "Could not find the main class. Program will exit.")
    After insuring that the manifest contained a Main-Class: argument and that the argument pointed to the right class, I started the jar via java -jar myjar.jar and read the stacktrace, which is much better than the popup-window.
    In my case the error was, that the Main-Class could not be loaded due to another referenced class, which was not on the classpath. (i.e. it was not in the same jar-File and the manifest didn't include a Class-Path: argument.)
    After adding the correct Class-Path: argument in the manifest, the problem went away.
    I now have the following setup:
    myjar.jar and somethirdparty.jar in the same directory.
    myjar.jar contains a manifest which includes the lines
    Class-Path: somethirdparty.jar
    Main-Class: my.package.and.MainClassafter the normal Manifest-header.

  • How to run an external TimeDate class

    package
         public class TimeDate
    var my_date:Date = new Date();
    trace(my_date:Date);
    mc_time.txt_displayDateTime.text = my_date:Date;
    Hi, I have a rough idea about displaying TimeDate in actionscript external class. Something like that above, but Im not sure what things did I miss out. I actually want it to display in mc_time.txt_displayDateTime(located at my main.fla stage). I'm not sure how to retrieve the TimeDate from the external class in my main.fla. Also displaying the TimeDate in mc_time.txt_displayDateTime and update the time every sec?

    Hi,
    I'm getting these errors:
    1046: Type was not found or was not a compile-time constant: Event.
    1078: Label must be a simple identifier.
    Warning: 1060: Migration issue: The method fscommand is no longer supported.  Moved to flash.system package. Also, please see flash.external.ExternalInterface class for Javascript/ActionScript communication..
    Warning: 1060: Migration issue: The method clearInterval is no longer supported.  This method has moved to the flash.utils package..
    Warning: 1060: Migration issue: The method setInterval is no longer supported.  Moved to the flash.utils package.  Consider using the Timer class instead..
    package
    public class TimeDate
    public function TimeDate(){
    this.addEventListener(Event.ADDED_TO_STAGE,init);
    private function init(e:Event):void{
    var my_date:Date = new Date();
    trace(my_date);
    mc_time.txt_displayDateTime.text = my_date:Date; <- error 1078 pointing to this line

  • How to run jsp using javabean class in tomcat

    hello all,
    i have bean class placed in classes folder of tomcat and placed jsp and html in root directory. i am not able to run it , if i have do any setting in web.xml, pls let me know from u

    No XML required, but you must put the class into a package.
    Packages are folders with some files that identify whats in them, so you will end up with something like
    yourWebbApp/classes/yourPackage/yourClass

  • How to run CS6 more effectively

    I made the jump from FCP7 to the Creative Suite for obvious reasons and I am in general happy with my transition except for the fact that while working with Premiere and After Effects together with RED 4K footage, my computer begins to slow down and heat up significantly. It is so bad that I don't feel I am wokring efficiently.
    Here are the specs for my 2011 MacBookPro
    OSX 10.8.3
    processor  2.3 GHz i7
    memory 8GB 1333 MHz DDR3
    Graphics  Intel HD Graphics 3000 512 MB
    I am more than willing to buy a new computer that can keep up with my editing demands (if that is the issue) but I want to make sure that I make the right purchase as I hear all kinds of different opinions on this matter:
    "Buy a PC."
    "Your graphics card is all that matters"
    ETC....
    Any help would be greatly appreciated.
    rand

    Edit 4k video http://forums.adobe.com/thread/1108124

  • How to extend property of main class

    hi all I hv made an class object in library that is mainBox.as , i hv  5 diffrent frames in it
    1) home (it contains 4 links about,images,history,contact)
    2) about
    3) history
    4) contact
    now i wanna trying to do when user on home frame that contains (about images,history,contact) inks and when user click on any link then it will jump on req. frame and then it's extended class will give the property... Like when user is in images then there can be an interactive image gallery, that will be handle through an extended class of mainBox class, so i wanna try to make diffrent pages to diffrent classes. you can find my source file through this link,
    https://sites.google.com/site/amit0shakya/home/extend-class-problem
    thank you
    [email protected]

    I think you have to use thread for concurrency>>>>..

Maybe you are looking for

  • DVI to HDMI or VGA to connect to HDTV

    Hi I am researching buying a 40-42" LCD or plasma TV and I would like to be able to connect my IMac to the tv. I will mostly be using the TV to watch sports and to watch videos from my IMac. 1. Will 1080p videos played from the IMac produce good 1080

  • When I try to download itunes I get the error message "ITunes.Setup_exe file could not be downloaded  Please help

    I had ITunes installed  up n running last November.  Few weeks ago I started getting error messages and said to reinstall ITunes to fix the problem.  So I went to control panel and deleted all Apple related programs, quick time n Itunes and reinstall

  • Designing ADF task flow for Human task

    Hi all, I have the following requirement. Find a participant from Active directory and assign the participant as manager (in business object) in ADF (taskdetails.jspx) Can you help me with the steps to implement the above requirement (on how to conne

  • Buisness Process monitioring

    I have set up the whole configuration and defined the process and everything in DSWP in "setup buisness process monitoring " . In setup BPM screen everything has been properly defined i took sales process "Account processing in ERP" and have RFC and

  • Work center HRMS link

    Hi , I know how to map people  to PM work center . But when i want to assign a person ...The server can't get me the person list . It looks like no HR data is connected in background . How should  we enable this ?? I.e how to connect HR server/table