How to make a jar file from a java file?

how to make a jar file from a java file, is there any one tht can help me thank you;

You can study this.
http://java.sun.com/docs/books/tutorial/jar/basics/index.html

Similar Messages

  • Trying to compile a .java file from another .java file

    Hello,
    I'm trying to compile a .java file from another .java file using Runtime.exec...
    String c[]=new String[3];
    c[0]="cmd.exe"; c[1]="/c" ; c[2]="javac Hello.java";
    Process p=Runtime.exec(c);
    If anyone can help me in atleast getting the command prompt when Runtime.exec("cmd.exe") is executed...that would be great...I tried out notepad.exe, calc, explorer instead of cmd.exe...all the commands display their respective windows..except cmd.exe...the command prompt doesnt appear...
    Please help me ASAP....
    Thanks for your help in advance...
    Regards.
    AKhila.

    try this. ur code will be compliled and will get .class file. but console won't appear. is it a must for u?
    public class Exec{
         public static void main(String a[]) throws Exception{
              String c[]=new String[3];
              c[0]="cmd.exe"; c[1]="/c" ; c[2]="javac Hello.java";
              Process p=Runtime.getRuntime().exec(c);
              // or Runtime.getRuntime().exec("javac Hello.java");

  • How to create windows executable file from a java file. Please help.

    Hi,
    For my project I developed the codes in Java. It is working well with java run time environment. But without that I can not run it. I need to create a exe file (windows executable file) from the java source code. If you have any idea please share it with me.
    Even if you know it very lightly, please help with what you know. That would be a big help for me.
    Thank you very much.

    Does anybody know how to read a manual?
    Matt Richardson
    Certified LabVIEW Developer
    MSR Consulting, LLC

  • How to make a "Program" out of my .java files?

    I have made a little application that stores a file to disk. Is there someway to make a file out of my .java files so it can be run without opening my editor and choosing run?

    sorry I didn't check that, I can now run the jar command.
    But even though I can create a .jar file I get an error. I have followed the guide that says I need to add the applications Entry point.
    I have two classes:
    saveDates.class //contains the main method
    UserInput.claa // Parsing of user input
    When I create the jar file I type:
    jar cfe saveDates.jar SaveDates SaveDates.class UserInput.class
    But when I try to run it like:
    java -jar saveDates.jar
    I get the error:
    C:\workspace\dato>java -jar saveDates.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: SaveDates$1
    at SaveDates.main(SaveDates.java:89)
    C:\workspace\dato>
    Do I need to change the main method someway?

  • How to run java source files from other java files??

    hello all,
    i need to run 3 to 4 .java files (first.java,second.java,third.java) from one file.
    i tried the
    Runtime.getRuntime().exec(cmd); but here cmd must be an exe file.
    NOTE THAT i need to run the first.java file ,second.java file each time to generate their .class files(ie I NEED TO COMPILE THEM ALL TIMES AND THEN RUN THEM)
    PLZ. help me if this can be done,
    warm regards,
    Vishal.

    One way to do this is to put all your commands into a batch file (this is Windows?) try unix shell otherwise. Anyway here's an example .bat file called cmplrun.bat:
    @echo off
    javac -classpath . TestCase*.java
    java -cp . TestCase01
    java -cp . TestCase02
    java -cp . TestCase03Then the Java pgm can look like this:
    import java.io.*;
    public class RunProcess {
      public static void main(String[] arg) {
        try {
          Process myProcess;
          myProcess = Runtime.getRuntime().exec("cmd /c cmplrun");
          String s = null;
          DataInputStream in = new DataInputStream(
                               new BufferedInputStream(
                                   myProcess.getInputStream()));
          while ((s = in.readLine()) != null) {
            System.out.println(s);
          System.exit(0);
        catch (IOException e) {
          System.out.println("Exception: "+ e);
          System.exit(-1);
    }Just one way to do this, all caveats apply and HTH;
    ~Bill

  • Why do I get multiple class files from 1 java file?

    I wrote a dialog box using gridBagConstraints and another program RunPanel to run it as a java application. For the first time since playing with java, I get multiple class files from a single java file.
    This seems very strange to me and wonder if anyone else has come across this and what could possibly be the reason for it. I did a clean (in Eclipse) just to make sure it wasn't garbage and sure enough they come back again.
    I have ReconPanel.java from which I get ReconPanel.class with the addition of ReconPanel$N.class where N goes from 1 to 5.
    The same thing in RunPanel but here there is only 1 extra file, RunPanel$1.class.
    I'll include the code for RunPanel since it is relatively small:
    package ilan;
    import javax.swing.JFrame;
    public class RunPanel extends JFrame {
         private static final long serialVersionUID = 1L;
         private ReconPanel m_reconPanel = null;
         public RunPanel() {
              super();
              initialize();
          * This method initializes this
         private void initialize() {
            this.setTitle("tester");
            this.setSize(new java.awt.Dimension(138,396));
            this.addWindowListener(new java.awt.event.WindowAdapter() {
                 public void windowClosing(java.awt.event.WindowEvent e) {
                      m_reconPanel.exitPanel();
                      System.exit(0);
              m_reconPanel = new ReconPanel();
              this.getContentPane().add(m_reconPanel);
          * @param args
         public static void main(String[] args) {
              JFrame frame1 = new RunPanel();
              frame1.setVisible(true);
    }  //  @jve:decl-index=0:visual-constraint="10,10"The only thing "unusual" I do is to put a listener on the WindowClosing so that I can go back to ReconPanel and write results to the registry.
    Can anyone tell me what is going on?
    Thanks,
    Ilan

    He IIan,
    Yes, you get number of extra class files based on your number of anomyous class es used. Like in your RunPanel, you get only 1 ..$1.class file, b'coz u have used only 1 annomyous class & i.e WindowAdapter. Take a look at this code :-
    this.addWindowListener(new java.awt.event.WindowAdapter() {
                 public void windowClosing(java.awt.event.WindowEvent e) {
                      m_reconPanel.exitPanel();
                      System.exit(0);
            });Similarly, in your ReconPanel, you must have used such kind of classes 5 times, & hence u get such 5 extra classes. To avoiod such extra classes, if you can directly implement that interface or extend the class, if possible will be best. For example, for each button, u write
    button1.addActionListener(new ActionListener() {
    // Code
    });Instead, of this, its better to implement ActionListener & write
    button1.addActionListener(this);
    public void actionPerformed(ActionEvent ae) {
       if (ae.getSource() == button1) {
       // CODE
       }Likethis, you can get rid of such numerous extra class files. In IDE, if you ask to add actionEvent, it will do the first method. To get rid of it, don't add event in the properties, instead, apply the second method. The same thing applies for anyother event. The first option is worthful, if by implementing, u got to write 5 functions from which u r gonna use just 1 method.
    Hope this clears your question.
    Trupti

  • How to call inner class method in one java file from another java file?

    hello guyz, i m tryin to access an inner class method defined in one class from another class... i m posting the code too wit error. plz help me out.
    // test1.java
    public class test1
         public test1()
              test t = new test();
         public class test
              test()
              public int geti()
                   int i=10;
                   return i;
    // test2.java
    class test2
         public static void main(String[] args)
              test1 t1 = new test1();
              System.out.println(t1.t.i);
    i m getting error as
    test2.java:7: cannot resolve symbol
    symbol : variable t
    location: class test1
              System.out.println(t1.t.geti());
    ^

    There are various ways to define and use nested classes. Here is a common pattern. The inner class is private but implements an interface visible to the client. The enclosing class provides a factory method to create instances of the inner class.
    interface I {
        void method();
    class Outer {
        private String name;
        public Outer(String name) {
            this.name = name;
        public I createInner() {
            return new Inner();
        private class Inner implements I {
            public void method() {
                System.out.format("Enclosing object's name is %s%n", name);
    public class Demo {
        public static void main(String[] args) {
            Outer outer = new Outer("Otto");
            I junior = outer.createInner();
            junior.method();
    }

  • Create .xml file from a java file

    I wanted to know how can we create a .xml file through java with the given data.
    For example: book saler.
    data given through java are
    1)Sl no
    2)Book name
    3Book type
    4)Book price
    i want a xml file generated through the java code
    can anyone help me out?

    i have done like this..
    but the problem with this is i want to add more than one book details. i am able to add only one book detais..
    package name:createxml
    main class:GenerateOrderXml.java
    CreateXml.java and order.java
    package createxml;
    import java.util.Vector;
    public class GenerateOrderXml {
         public static void main(String[] args) {
              try{
              Order order= new Order();
              CreateXml xml=new CreateXml();
              Vector orders=new Vector();
              order.setBookName("Java_for_beginers");
              order.setAuthorName("Balaguruswamy");
              order.setISBN("a123");
              order.setNo_of_copies("3");
              order.setprice("350");
              order.setPublisher("Deepak publishers");
              orders.add(0,order);
              order.setBookName("Java");
              order.setAuthorName("Bala");
              order.setISBN("a123");
              order.setNo_of_copies("3");
              order.setprice("350");
              order.setPublisher("Deepak ");
              orders.add(1,order);
              xml.creatxml(orders);
              catch(ArrayIndexOutOfBoundsException e)
                   e.printStackTrace();
    package createxml;
    import org.jdom.*;
    import org.jdom.output.XMLOutputter;
    import java.io.IOException;
    import java.util.Vector;
    * @author divyashree
    * To change the template for this generated type comment go to
    * Window - Preferences - Java - Code Generation - Code and Comments
    public class CreateXml {
         public void creatxml(Vector orders)
         try
                   Element root = new Element("BookSaler");          
                   Order order= new Order();          
                   order=(Order)orders.elementAt(0);
                   Element BName = new Element("Bookname1");
                   BName.setText(order.getBookName());
                   root.addContent(BName);
                   Element AName = new Element("Authorname");
                   AName.setText(order.getAuthorName());
                   BName.addContent(AName);
                   Element isbn = new Element("ISBN");
                   isbn.setText(order.getISBN());
                   BName.addContent(isbn);
                   Element price = new Element("Price");
                   price.setText(order.getprice());
                   BName.addContent(price);
                   Element publisher= new Element("Publisher");
                   publisher.setText(order.getPublisher());
                   BName.addContent(publisher);
                   order=(Order)orders.elementAt(1);
                   Element BName1 = new Element("Bookname2");
              BName1.setText(order.getBookName());
              root.addContent(BName1);
              Element AName1 = new Element("Authorname");
              BName1.addContent(AName);
              Element isbn1 = new Element("ISBN");
              isbn.setText(order.getISBN());
              Element price1 = new Element("Price");
              BName1.addContent(price);
              Element publisher1= new Element("Publisher");
              BName1.addContent(publisher);
              Document doc = new Document(root);
              try {
                   XMLOutputter serializer = new XMLOutputter();
                   serializer.setIndent(" ");
                   serializer.setNewlines(true);
                   serializer.output(doc, System.out);
              catch (IOException e)
                   System.err.println(e);
         }catch(ClassCastException e)
              e.printStackTrace();
    package createxml;
    import java.util.Vector;
    public class Order {
         protected String ISBN="";
         protected String BookName="";
         protected String AuthorName="";
         protected String No_of_copies;
         protected String price;
         protected String Publisher="";
         public String getISBN()
              return this.ISBN;
         public String getBookName()
              return BookName;
         public String getAuthorName()
              return AuthorName;
         public String getNo_of_copies()
              return No_of_copies;
         public String getprice()
              return price;
         public String getPublisher()
              return Publisher;
         public void setISBN(String isbn)
              Vector vec_isbn= new Vector();
              ISBN=isbn;
         public void setBookName(String bookname)
              BookName=bookname;
         public void setAuthorName(String authorname)
              AuthorName=authorname;
         public void setNo_of_copies(String no_of_copies)
              No_of_copies=no_of_copies;
         public void setprice(String Price)
              price=Price;
         public void setPublisher(String publisher)
              Publisher=publisher;
    /***************************************************************************/

  • How to call a .jar file from a java bean?

    any body knows how to call a .jar file from a java bean?

    Crosspost!
    http://forum.java.sun.com/thread.jspa?messageID=4349619

  • How to make a searchable PDF from an AutoCAD DWG file

    We have PDF files created from AutoCAD, but they are not searchable using Adobe Reader X.  I checked the source DWG file to find what font was used, as suggested in an old post, and found that the DWG uses Arial font.  I am not sure what version of AutoCAD was used to create the file, but I can open it with AutoCAD LT 2011.  Can anyone guide me to a way to make searchable PDF files from these DWG files?

    Ok, this is as I feared; something CAD programs are particularly likely to do is draw text with a pen, rather than use text. There might be options in AutoCAD to control this.

  • How do I remove padlock icon from all my files?

    On one of my drives, every single file has a little padlock icon superimposed over the file icon. I recall when I did a clean install of windows 7 RC over my Vista install, I wasn't getting write access to the drive so I had to take ownership of the drive and mess with the security settings before it started working normally.
    I have to admit, I find the security settings in all versions of NT mystifying... For instance, although my account is in the administrators group, having full access to administrators never seems to work. I always have to add my individual user account and explicitly give it full access.
    In any case, I can't remember exactly what it took, but after messing around with the security settings for a while, I eventually was able to have full access to the drive and have no problems reading/writing/deleting files and folders, but there's the padlock icon still on everything.
    Can anyone explain how to get rid of it, and/or maybe point me to a good, clear, understandable guide on how to properly set NTFS permissions.
    Thanks!

    <form id="aspnetForm" action="edit" enctype="application/x-www-form-urlencoded" method="post">
    <input id="__VIEWSTATE" name="__VIEWSTATE" type="hidden" value="/wEPDwULLTEzNzk0MzkwMDlkZD6SorGRLWx4w+alHb7GRMyulXR+" />
    </form>
    Windows Client TechCenter
    <input id="SearchTextBox" class="TextBoxSearch TextBoxSearchIE7" name="SearchTextBox" type="text" /><input id="SearchButton" class="SearchButton" name="SearchButton"
    src="http://i1.social.microsoft.com/globalresources/Images/trans.gif" type="image" /> 
    Sign out
    United States (English)
    Australia (English)Brasil
    (Português)Česká republika (Čeština)Danmark
    (Dansk)Deutschland (Deutsch)España
    (Español)France (Français)Indonesia
    (Bahasa)Italia (Italiano)Magyarország
    (Magyar)România (Română)Singapore
    (English)Türkiye (Türkçe)Россия
    (Русский)ישראל (עברית)المملكة
    العربية السعودية (العربية)ไทย (ไทย)대한민국
    (한국어)中华人民共和国 (中文)台灣
    (中文)日本 (日本語)香港特別行政區
    (中文)
    ZYBORG
    Resources for IT Professionals
    HomeWindows 7Windows VistaWindows
    XPLibraryForums
    Windows Client TechCenter >
    Windows 7 IT Pro Forums
    > Windows 7 Security
    > How do I remove padlock icon from all my files?
    > a9d3326a-9af4-4d81-9f6e-0df9575b4fea
    <form action="/Forums/en/w7itprosecurity/thread/16474fcf-688b-4eae-88f4-804306bafc0f/a9d3326a-9af4-4d81-9f6e-0df9575b4fea/edit" enctype="application/x-www-form-urlencoded" method="post">
    Edit Message
    <textarea cols="100" rows="20" name="body"><blockquote> <p>Hi,</p> <p>This is a new feature of Windows 7 RC. If a folder's ownership is SYSTEM, the icon would be appears.</p> <p>To
    remove the icon, please change the ownership of the folders. You may refer the following website.</p> <p><a href="http://www.vista4beginners.com/Change-permissions-take-ownership">Change the permissions and take ownership of your
    files and folders&nbsp; Windows Vista for Beginners</a>&nbsp;</p> <p>Important Note: Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft
    does not guarantee the accuracy of this third-party contact information.</p> <hr> Arthur Xie - MSFT</blockquote> <p>You may call this a feature but I call it rediculous. The security and ownership system deployed in win 7 is beyond
    belief and horribly BAD!</p> <p>I have files which have disappeared from view under start / all programs which are clearly on my system. They can be seen by an administrator only account but not by a users acccount which has administrator privs.
    That really makes great since!</p> &nbsp;Returning to Win XP looks like a good option to me. Anyone who changes the ownership of an entire drive is asking for latent problems when various areas within windows needs ownership of SYSTEM or Trustedinstaller
    and others which were overwritten with the change.</textarea>
    <label for="hasCode">Resource.HasCodeLabel</label><input name="hasCode" type="checkbox" value="true" /> <label for="reason">Reason</label><input name="reason" type="text"
    />
    <input title="Submit" type="submit" value="Submit" />
    </form>
    Need Help with Forums? (FAQ)
    © 2011 Microsoft. All rights reserved.
    Terms of Use|Trademarks|Privacy Statement|Contact
    Us
    <script type="text/javascript"></script> <script type="text/javascript"></script> <script type="text/javascript"></script> <noscript></noscript> <noscript></noscript>
    This forum even has bugs! look at this mess.

  • How to create a .DLL file from a .C file ?

    Hi everybody
    I'm looking for a method how to create a .DLL file from a .C file .That Dll file will be used to perform a board to measure voice quality accoding to the international standard named PESQ (perceptual evaluation of speech qualty) P.862.
    Can anyone help to start dealing with Dlls and give some advices to avoid errors ?
    thx
    Attachments:
    source.zip ‏37 KB

    Hi sinaps,
    You mention that you want to create a DLL from a .C file. Just to clarify, are you using C (.c file) or C++ (.cpp) to write your code?
    Also, if you are using C++, are you using Visual Studio? (The reason I ask is because this forum is geared towards Measurement Studio, which is an add on to Microsoft Visual Studio).
    That being said,
    If you are using C: National Instruments provides an ANSI C Application Development Environment called LabWindows/CVI which makes building dlls a snap. It has templates for DLLs and you can build them either as stdcall or cdecl dlls.
    Developer Zone Tutorial: Building a DLL with LabWindows/CVI 8.5 for use with LabVIEW 8.5
    If you are using Visual C++: Look at the link that Al provided earlier.
    MSDN: Walkthrough: Creating and Using a Dynamic Link Library
    If you aren't using CVI or Visual Studio, then really the best bet is to do a google search for "Create C DLL" or post or a forum for the appropriate environment that you are using.
    Thanks!
    Message Edited by Jervin_J on 03-14-2009 02:02 PM
    Jervin Justin
    NI TestStand Product Manager

  • How to make a snapshot out of a movie file?

    How to make a snapshot out of a movie file and integrate this snapshot into the movie? Thanks, Wolfgang

    Either you use the Hold function from the Retiming popup or you export an image and reimport it.

  • How do you convert a jar file into a java file,  ?

    how do you convert a jar file into a java file ?
    I am new to Java ,but have a little experience in C++ and Visual Basic.
    I want to edit and maybe create my own mobile games that are written or converted into jar files.
    At the moment I am using Java NetBeans , and Easy Java( the java pad).
    However the only solution I tried was to open the JAR file in winrar and see that its made up of png picture files,
    midi music files and class files. Unfortunately when I uncompressed the JAR file , there was NO java file to be seen and the JAVA editors Do not show the class file like a Java file. So why is there no extension Java file in the mobile JAR game ?

    801283 wrote:
    how do you convert a jar file into a java file ?You generally don't. There exist decompilers, but if you're meant to have the source, you should either have it because you are the author, or you should be able to get it from the author.
    I am new to Java ,but have a little experience in C++ and Visual Basic.Does that experience include turning .exe files into C++ code? Because that's the equivalent of what you're asking
    I want to edit and maybe create my own mobile games that are written or converted into jar files.Eh?
    Are you saying you want to take existing games and modify them? If the creators allow you to modify their source, then they'll provide you with that source (the .java files). If you're allowed to add things but not modify, you don't need .java files. Just documentation, which, again, the creators should be providing.
    Or are you saying you want to create your own games and distribute them in jar files? If so, there's no need to turn jars into .java.
    However the only solution I tried was to open the JAR file in winrar and see that its made up of png picture files,
    midi music files and class files. Unfortunately when I uncompressed the JAR file , there was NO java file to be seen and the JAVA editors Do not show the class file like a Java file. So why is there no extension Java file in the mobile JAR game ?Why would you expect there to be one?

  • How do i move a picture from one pdf-file to another already created pdf-file with adobe reader?

    How do I move a picture from one pdf-file to another, already created pdf-file, with adobe reader?

    Reader doesn't have editing capabilities.

Maybe you are looking for

  • Is there a way to disable stereo bluetooth in OS3 but keep Hands Free?

    Hi All, I've been a huge fan of my 3G since purchasing it last September and have adored it even more since buying my 2009 Acura TSX. The car and phone seemed built for eachother and have worked seamlessly together since I bought the car in November.

  • Need to create a chart in summary page and link it to data

    I need to create a chart in a XL worksheet that contains other summary information. I am able to create a chart in a seperate sheet but i simply cannot find a way to insert a chart into a worksheet already containing some information. To make it clea

  • Problem with ArrayDescriptor

    Hi All, In Oracle I have a problem in the code at line ArrayDescriptor descriptor =ArrayDescriptor.createDescriptor("STR_ARRAY",con); where STR_ARRAY is declared in the DB as: CREATE TYPE STR_ARRAY AS TABLE OF VARCHAR2(2000); It was working fine, bef

  • Are text messages included in auto backups to computer?

    Hi, I have a fresh iPhone 4 backup on my laptop. Does it include text messages? And if so, will a sync to a new iPhone 5 add the text messages to the new phone? My problem is that my screen has died, and I did not have iCloud activated. And I can't a

  • Help with jsp (timer)

    Greetings, I'd like to know whether following possible or not - perform a task that will make something when time goes out (like an auction system) with visual preview of ticking counter (24:00, 23:59 ... etc. when the page refreshed)?.. Or I should