Running eclipse java project on command prompt

Hi all,
I have one simple java project and that is very well running in eclipse. I have added some external JARs to that project. It performs this job- it creates connection to server, and listens to the signals from server.
My question is - how do I run that java project on command prompt?*
I want to run that using ANT or simply I want to make a JAR file so I can execute JAR on command prompt. I created JAR, but it doesn't contain external jar which I added to the project. So I was not able to run that project.
Can you please tell me any of the method - using ANT or by making JAR?
Also can you be little bit more explanatory in reply?
Thanks

I want to make a JAR file so I can execute JAR on command prompt.This is very likely a good way to proceed. It is explained in great detail in Sun's Tutorial in the section on [Packaging Programs in JAR Files|http://java.sun.com/docs/books/tutorial/deployment/jar/index.html].
I created JAR, but it doesn't contain external jar which I added to the project. So I was not able to run that project.Yes - the jar file you create has to know about the classes and other resources in that external jar. Otherwise, at runtime, the program will not be able to get at the stuff it needs. Usually you don't include that other jar (or its contents) in the jar file you are creating. Instead you provide your jar file with a manifest that describes the other jar's location. Details are also in the tutorial.
One thing to note is that Sun's tutorial provides a lot of explanatory, conceptual, material. To that end it keeps the context simple and transparent by describing the steps as they would be carried out by someone working at the command line. The Eclipse documentation and forums might provide a more click-this-drag-that "explanation". If you do follow the method in the Tutorial and get stuck, post a description of the actual commands you used and their outcome.

Similar Messages

  • How to Compile java project on command prompt

    Hello Friends,
    I have created one java project in eclipse. It has 3 packages, 4 external jars and one Link source (meaning it uses other java package that is not in the same project folder)
    It runs perfectly using eclipse.
    Now I want to compile my project and want to run that project.
    I tried using "javac -classpath........." but it didn't work for me. Here is the command I used:
    I am running this command under my main project folder
    javac -classpath ./../../../lib/tools/lib/blur/blur_formats-1.0.jar;./../lib/commons-codec/commons-codec-1.3.jar;./../lib/commons-httpclient/commons-httpclient-3.1.jar;./../lib/commons-logging/commons-logging-1.1.1.jar;./../lib/org.json/org.json.jar;./../lib/smack/3_0_4/smack.jar;./../../../device/branches/viper/Service/blur/common/push/src* ./src/com.proj.hnm.push.StartService.java*
    1) /device/branches/viper/Service/blur/common/push/src - is a different package I am referring (not in my current project folder) - it has java files in com.pushsync package
    2) ./src/com.proj.hnm.push.StartService.java is my main class, com.proj.hnm package also contains another 2 package, and those other packages also have .java files
    Please tell me how do I run my java project?
    Thanks

    Hi
    Since it works fine in Eclipse you should install the [Fat Jar eclipse plugin|http://fjep.sourceforge.net/] which will pack everything thats in your eclipse project into a single jar file. Then you can run: java -jar myProject.jar and it should work.

  • How to run a java program in command prompt

    hi i want to run a java program from in command prompt from another directory
    i want to run a file named First in C:\Program Files\Java\jdk1.6.0_07\bin
    so when i give the command
    java "C:\Program Files\Java\jdk1.6.0_07\bin\First"
    it doesnt works it shows
    C:\>java "C:\Program Files\Java\jdk1.6.0_07\bin\First"
    Exception in thread "main" java.lang.NoClassDefFoundError: C:\Program Files\Java
    \jdk1/6/0_07\bin\First
    Caused by: java.lang.ClassNotFoundException: C:\Program Files\Java\jdk1.6.0_07\b
    in\First
    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 the main class: C:\Program Files\Java\jdk1.6.0_07\bin\First. Pro
    gram will exit.

    but it prints
    C:\>java -cp "C:\Program Files\Java\jdk1.6.0_07\bin\" First
    Usage: java [-options] class [args...]
    (to execute a class)
    or java [-options] -jar jarfile [args...]
    (to execute a jar file)
    where options include:
    -client to select the "client" VM
    -server to select the "server" VM
    -hotspot is a synonym for the "client" VM [deprecated]
    The default VM is client.
    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    A ; separated list of directories, JAR archives,
    and ZIP archives to search for class files.
    -D<name>=<value>
    set a system property
    -verbose[:class|gc|jni]
    enable verbose output
    -version print product version and exit
    -version:<value>
    require the specified version to run
    -showversion print product version and continue
    -jre-restrict-search | -jre-no-restrict-search
    include/exclude user private JREs in the version search
    -? -help print this help message
    -X print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
    enable assertions
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
    disable assertions
    -esa | -enablesystemassertions
    enable system assertions
    -dsa | -disablesystemassertions
    disable system assertions
    -agentlib:<libname>[=<options>]
    load native agent library <libname>, e.g. -agentlib:hprof
    see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
    load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
    load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
    show splash screen with specified image
    C:\>

  • Running a java application in command prompt

    hi, I'm new to this forum.
    I would like to know what exactly needs to be specified to run a java application in a normal DOS command prompt.
    I know it is something like:
    javaw -classpath .\class GUI.applicationGUI
    where applicationGUI is the main class, right? What else do I need to do, since I have some other non-GUI classes that I need, inside the class folder ?
    Thanks for your time.

    You need to import those classes. And you need to make packages.
    In classes 1, 2 and 3 put:
    package class;
    In class 4 put;
    package class.GUI;
    Then you need to make the connection:
    In classes 1,2 and 3 put:
    import class.GUI.*;
    In class 4 put:
    import class.*;
    Compile each directory separately while in the respective directory. javac *.java
    Then go back to the directory above the directory "class" and run
    java class/GUI/name_of_file_containing_main_method

  • How can i run application client from the command prompt ?

    Hi,
    I'm new to java & EJB. so can any body tell me the command to run the application client from the command prompt. Here is the code to print hello world:
    /* Remote interface */
    public interface Hello extends javax.ejb.EJBObject
         public String hello() throws      java.rmi.RemoteException;
    /* Home interface */
    public interface HelloHome extends javax.ejb.EJBHome
         Hello create() throws java.rmi.RemoteException, javax.ejb.CreateException;
    /* Stateless session bean class */
    public class HelloBean implements javax.ejb.SessionBean
         private javax.ejb.SessionContext ctx;
         public void ejbCreate(){
              System.out.println("ejbcreate()");
         public void ejbRemove(){
              System.out.println("ejbRemove()");
         public void ejbActivate(){
              System.out.println("ejbActivate()");
         public void ejbPassivate(){
              System.out.println("ejbejbPassivate()");
         public void setSessionContext(javax.ejb.SessionContext ctx){
              this.ctx=ctx;
         public String hello(){
              System.out.println("hello()");
              return "Hello, world!";
    /*Client class */
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import java.util.Properties;
    public class HelloClient
         public static void main(String[] args) throws Exception{
              Properties props=System.getProperties();
              Context ctx=new InitialContext(props);
              Object obj=ctx.lookup("HelloHome");
              HelloHome home=(HelloHome)javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class);
              Hello hello=home.create();
              System.out.println(hello.hello());
              hello.remove();
    I have stored .java files in c:\ejb
    I have successfully created the .class files using javac command in the following directory :
    c:\ejb
    I have also created Helloworld.ear file in c:\ejb using sun application server which contains the following files:
    ejb-jar-ic.jar
    app-client-ic.jar
    sun-j2ee-ri.project
    application.xml
    sun-application.xml
    Manifest.mf
    But the problem is that i'm not able to run the HelloWorld.class file successfully from the command prompt. So please suggest me the comand.
    Thanx in advance.
    Best regards,
    Pankaj

    Hi
    You can run this code from the command prompt in the same way as you run any other simple java program. The only thing is you need to set the Home and Local interfaces in the classpath.And obviously if u had deployed the bean in ur app server container, then its all over.
    And one more thing is that u need to set the provider URL in the InitialContext created in the client program.
    Thanks
    Arun B

  • Error while running a ODI scenario from command prompt

    Hi,
    I'm trying to run a ODI scenario from command prompt. I've edited the tnsnames.ora and odiparam.bat file with exact host and port details. Even though I'm facing the below error.
    command:startcmd.bat OdiStartScen -SCEN_NAME=INT.CUSTOMER_STG -SCEN_VERSION=001 -CONTEXT=ICM -AGENT_CODE=KANBAN
    Error: java.sql.SQLException: Listener refused the connection with the following error:
    ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
    The Connection descriptor used by the client was:
    localhost:1521:orcl
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:280)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:328)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:361)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:151)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:595)
    at com.sunopsis.sql.SnpsConnection.u(SnpsConnection.java)
    at com.sunopsis.sql.SnpsConnection.c(SnpsConnection.java)
    at com.sunopsis.sql.i.run(i.java)
    Please help in resolving the error...
    Thanks in advance.
    Edited by: 894841 on Dec 22, 2011 11:15 PM

    Hi,
    Are you able to start the Standalone Agent(KANBAN) and test it in the Topology?
    Check the value of the ODI_MASTER_URL variable in odiparams file(at the path <ODI_HOME>\oracledi\agent\bin) of the agent.
    Specify the full the JDBC URL properly not like localhost(until the DB is on same machine as your ODI).

  • How to run a Java project in NWDS...

    Hi All,
    First of all , i dont know if i am writing in the right forum for this question.
    I am new in NWDS.
    My question is, how can i run my java project in NWDS without  having any portal available (we had some problems running projects in EP 2004 and so we will install a new version EP 2004s )?
    Thank you!
    Regard,
    Ari

    Hi Lohi,
    Thank you for your help.
    Yes i am creating Ear file by using the Java programs with NWDS .
    You mean to deploy mannualy with SDM inside my server?
    How can i than, utilize that into IE?
    Can i run ear without using EP.
    Sometimes i want to run my project in my house where i dont have acess in any SDM or everything else.
    Can you give me please more step by step instruction because i am new with these technologies.
    Thank you ,
    Ari

  • How to run non-customised report from command prompt to gen trace file?

    Hi
    how to run non-customised report from command prompt to gen trace file?
    EBS R12 RUP6.
    RHEL5
    rgrds

    Hi,
    See (Note: 285497.1 - Rwrun.sh Does Not Generate Trace Output Using TRACEOPTS in Command Line) and/or (Note: 737445.1 - R12 Concurrent Requests Run Forever; rwrun Errors REP-50125) for the command you need to use.
    Thanks,
    Hussein

  • Running a plain java class in command prompt which uses third party jars

    i have to run a simple java class. its actually a process which is running in the background. Now to run this java file i have created a batch file. my problem is that this java file uses around 100 jar files. when i try to run this java file (actually .class file) it gives me no class defination found error for this java(class) file. What can be the problem. My java home is set....how to solve this problem

    i have to run a simple java class
    my problem is that this java file uses around 100 jar filesThese two statements are contradictory.
    it gives me no class defination found error for this java(class) file. What can be the problemThe class is not on the classpath.
    how to solve this problemEnsure all classes are on the classpath.
    I bet if your searched this forum (or even read the java tutorial) you'd find something .

  • Using Java in windows command prompt

    Hi,
    I don't know if I have been searching correctly, but I haven't found a solution to my problem through common search engines.
    I'm programming in java using vim (accessed through windows command prompt), and I've created classes, everything compiles fine.
    However, I wanted to test my classes my creating instances of them (i.e. objects) through the same windows command line (command prompt). I know you can achieve this by using interaction panes through third party programs such as Dr.Java and eclipse, but I was wondering if this can be done using the command line.
    Thanks
    Jaime

    Thanks Paulcw for your quick reply! :D
    I'm guessing I didn't word my question properly.
    Neither of my classes have a main method in them, so when I am trying to create instances (objects) of them, I would like to as if my command line was the main.
    For example:
    Class1 c = new Class1(parameters);
    c.moveRight();
    etc.
    I'd like to be able to use my classes methods from the command line, I think what I'm looking for is a batch, but I'm not sure.
    Thanks again,
    Jaime

  • How to run a java project based on x86 Windows XP on Windows CE?

    I am a freshbird of J2ME and i am very confused these days.I beg you can look this topic thoughout.
    I used to configurate a Java Project File about SIP&VOIP successfully,and I can run it well on my PC .
    Now I want to migrate the project to a Mobile OS,and problems comes.
    I have installed the Windows CE 5.0 Evalution Edition on my machine(Windows XP SP2) and it works fine.I search it online for days ,and I download almost all related including CLDC(j2me_cldc-1_1-fcs-src-winunix.zip),MIDP(midp-2_0-fr-spec.zip<==Maybe this is not the right one beacuse it don't have a bin folder),and J2ME Wireless Tool KIt(j2me_wireless_toolkit-2_2-ml-windows.exe).
    I have configrate the enviroment-variable already , but I don't kown what to do next . Do you kown? I would be very thankfull.

    You need to completely rewrite the app to use the mobile APIs as they're very different from the PC ones, I suppose.

  • Running quicktime 7.0 from command prompt

    Greetings.
    I'd like to start QuicktimePlayer 7.0 from the command prompt on windows 2003 server. I can start Quicktimeplayer but the movie doesn't play. Any idea how this can be done ? Also, is it possible to start the movie at particular place in the file ? For exmaple, can the movie be started 5 minutes from the beginning and run for 3 minutes ?
    Thanks.
    alan

    I have not tried BMP files, but do JPeg, GIF, TIFF, and PNG files regularly. I simply open Acrobat, then select the graphics files in explorer and drag & drop to Acrobat. I then organize the graphics if needed (using the pages tab) and save to a PDF.

  • Run mapname.pls in windows command prompt

    Hi all,
    I am using owb 10gR2. I created one mapping and it is running fine through debugging. but while validation and generation,it is generating one pl sql script in the format of mapname.pls. I just want to run the script in windows command promt and sql plus.
    Is it possible?? If it is possible,can you pls help me out and tell me the steps??
    Thanks in advance,
    Bharath.

    Hi Bharath,
    to run a mapping you must deploy it first using control center manager. The code that is generated in the design center client has only informational purpose.
    To get an idea on how to work with owb check out the online tutorials: [http://www.oracle.com/technology/obe/admin/owb_main.html|http://www.oracle.com/technology/obe/admin/owb_main.html]
    Regards,
    Carsten.

  • Interfacing Java with the command prompt

    Hi everyone,
    I'm very new to java and wanted to see if anyone had any advice before i started getting too far into this project. I want to write a java program which allows the user to draw lines on the screen, and move them around, and then the program will compute the equations of these lines and feed them into another program to study the algebra behind the geometry.
    I've written an applet which is a start towards what I want: http://math.berkeley.edu/~aboocher/Mouse2.html but I'm encountering problems since it seems very difficult to have an applet write to a file, so I started trying to just create a self-contained java program. Before I move further I was hoping someone could point me in the right direction.
    Ultimately I would like a window where the user can draw some geometric objects and the computer will write the equations to a file and then when I click "compute" say, it will run my other program (which can be done from the command line) and display "true or false"
    In case it matters, I'm on a Mac and the exterior program is called Macaulay 2.
    Thanks for your help!

    That seems highly reasonable.
    If your going to be writing to a file, it would probably be a better approach to create an application.
    As for the arithmetic part of it, you'll want to save the points that the lines dropped, to use for future calculations. Using arrays would probably be a good idea.
    You'll also want to reduce the flickering problem with your applet on the website you linked to. Maybe double buffer? Along with using arrays to recall previous lines

  • Enable Security in Eclipse Java project on Netweaver

    Hi All,
    I am working on a standalone requirement, wherein I have an dynamic web project in eclipse and a few JSP pages calling web services etc.
    After the coding is done, I am testing it using my local Tomcat server and it works fine.
    now I want to deploy this on my Netweaver. I exported the EAR and and got it deployed on Netweaver using NWDS.
    The application works fine there too.
    But the problem is that even though the application is running on Netweaver, it does not ask for authentication and runs freely.
    Is there a way to add security into it?
    Please help in this regard.
    G

    Protecting Java Web Applications - Integrating Security Functions - SAP Library

Maybe you are looking for