Going from .java source files to a .jar

If my source files are .java, how can I make a .jar out of them from the command line? I have 4 main files, each a class with plenty of inner classes...how do I turn those files into something jar.exe wants? And if/when I get the .jar archive created, how do I set the class with the main class? Thanks for any help guys and gals!
Fair

This is not new info, just restating previous replies 1 and 2. (In case there's a misunderstanding...)
You must create class files by compiling xxx.java with the java compiler, this creates xxx.class, which contains an intermediate 'bytecode' version of the source - it's not readable by humans. The xxx.class file can be interpreted (run) by the java interpreter, thus: java xxx **OR** it can be placed in a jar file, and if done properly the jar file is executable.The 2nd reply by kelle3 gives the way that the jar file is created. If the xxx.class file(s) can be interpreted, they are valid. I'm not sure what you're looking at when you say you 'opened mine', as that requires that you disassemble a class file, which I don't think you're doing.
If you're still having problems either 1) search the forums for '.jar', there are many threads like this, or 2) go here http://java.sun.com/docs/books/tutorial/jar/basics/index.html
Hope this assists.

Similar Messages

  • Error running batch files from java source file???

    Dear Friends,
    hi,
    this is with response to a doubt i had earlier ,
    i want to run batch files from the java source file ,i tried using this code (here batrun is the batch file name that contains commands to run other java files)
    try
    String [] command = {"c:\\vishal\\finalmain\\batrun"};
    Runtime.getRuntime().exec(command);
    catch(Exception e)
    but i got the following error.
    java.io.IOException: CreateProcess: gnagarrun error= 2
    plz. help me, i tried all combination w/o success,
    in anticipation(if possible give the code after testing)
    Vishal.

    hello there,
    i solved the prob. by using
    cmd /c start filename ,but i need to pass parameters ie
    cmd /c start java "c:/vishal/runfile a b" where a and b are the parameters. but it is not accepting this in Runtime.getRuntime.exec(),
    any solutions ?????????
    regards,
    Vishal

  • Passing variable from one java source file to another

    i have one java source file
    one.java
    class one {
    long a;
    a = somevalue;
    i have another java source file
    second.java
    class second{
    long b;
    // here i need to assign the value of a i.e from one.java to b
    i am in great confusion and begineer of java
    plz plz help me

    a couple of possibilities are
    pass a parameter to the constructor
    or
    use the reference to class Two to call a method in class Two that takes a parameter and sets the value of the attribute in class Two.

  • How can I share a *.java source file across multiple projects in NetBeans?

    I'm sure this simple and a pretty common operation but how can I share a *.java source file across multiple projects in NetBeans? Right now I keep cut, coping and pasting the same source file between multiple projects to re-use the same code. But I could I make this source file a library file or something like that so that I could access it from any project. I assume this would be a generic operation but I mentioned NetBeans for clarity. Thanks.

    fiebigc wrote:
    I know I mentioned NetBeans but I'm most interested in the generic method for creating a library of source files that I can call into whatever program I am developing. I've done such a thing in C using header files and such but I'm trying to get a direction on how this is accomplished in Java. I'm sorry if I could edit the title I would. If anyone wants to be specific about NetBeans I welcome that too.
    Edited by: fiebigc on Jun 20, 2008 5:57 PM
    >I know I mentioned NetBeans but I'm most interested in the generic method for creating a library of source files that I can call into whatever program I am developing. I've done such a thing in C using header files and such but I'm trying to get a direction on how this is accomplished in Java. I'm sorry if I could edit the title I would. If anyone wants to be specific about NetBeans I welcome that too.
    Edited by: fiebigc on Jun 20, 2008 5:57 PM
    Create a class library.
    Write your code, compile it to .class files, put those class files in a .jar file and include the jar file in the classpath whenever you want to compile a project against it.

  • Error while compiling the ejb java source files.................

    hi,
    i am new to ejb.......
    i have got error while compiling the ejb java source files............
    while compiling..........of this three i ahve got err in ejb home interface....
    ejb remote interface - succeded
    ejb bean class - succeded
    ejb home interface - error
    the error..............is in the return type of the ejb create() method in ejb home interface(which is the type of remote interface).
    the error message is cannot resolve symbol

    Hi,
    thanks for ur reply .....
    i have done enough searching in all sites including sun forum but in vain
    i have pasted my error below...
    can u plz predict anything from it
    D:\>path=%path%;c:\j2sdk1.4.2_12\bin;
    D:\>set classpath=%classpath%;d:\Sun\AppServer\lib\j2ee.jar;
    D:\>javac d:\Librarys\Library.java
    D:\>javac d:\Librarys\LibraryBean.java
    D:\>javac d:\Librarys\LibraryHome.java
    d:\Librarys\LibraryHome.java:8: cannot resolve symbol
    symbol : class Library
    location: interface Librarys.LibraryHome
    public Library create(String id, String name, String address, String phoneNo
    ) throws RemoteException, CreateException;
    ^
    d:\Librarys\LibraryHome.java:9: cannot resolve symbol
    symbol : class Library
    location: interface Librarys.LibraryHome
    public Library findByPrimaryKey(String id) throws FinderException, RemoteExc
    eption;
    ^
    2 errors
    thanks in advance...

  • Read from external source file in weblogic

    Hi,
    I am using Weblogic Server 10.3 in my project.
    In one of my modules , i have a requirement where I have to read the contents of a file from an external location.[ex: D:\Test\Sample.xml ].
    How to i configure this path in weblogic , so that I can read the content in my java source file.
    Please advice.
    Regards,
    Praveen

    only part i replied on was the part of how to read a file
    but i think in your case you could do the next
    use the sync file adapter to read in the file during your process
    based on this content you set a variable "myOutputDirectory"
    then create a file adapter (write) which will store the file on file system
    http://docs.oracle.com/cd/E23943_01/integration.1111/e10231/adptr_file.htm#CIACICFD
    4.3.2.2.5 Specifying a Dynamic Outbound File Name
    and use that (jca.file.Directory) property to store the file either on the archive location or the delete location

  • The command oracg fails to generate Java source files

    I tried to use the command 'oracg -schema Openshipments.xdr' to generate Java source files from
    XML schema file Openshipments.xdr . Although the schema file is valid, the command oracg fails with following error messages :
    file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column 47>:
    XSD-2026: (Error) Invalid attribute 'name' in element 'element'
    file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column 47>:
    XSD-2030: (Error) Element 'schema' has invalid namespace:
    'urn:schemas-microsoft-com:xml-data'
    file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column 47>:
    XSD-2027: (Error) Invalid element 'ElementType' in 'schema'
    file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column 47>:
    XSD-2027: (Error) Invalid element 'ElementType' in
    'schema'file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column
    47>: XSD-2027: (Error) Invalid element 'ElementType' in 'schema'
    file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column 47>:
    XSD-2027: (Error) Invalid element 'ElementType' in 'schema'
    file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column 47>:
    XSD-2027: (Error) Invalid element 'ElementType' in 'schema'
    file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column 47>:
    XSD-2027: (Error) Invalid element 'ElementType' in
    'schema'file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column
    47>: XSD-2027: (Error) Invalid element 'ElementType' in 'schema'
    file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column 47>:
    XSD-2027: (Error) Invalid element 'ElementType' in 'schema'
    ...... the above line is repeated many times
    Error: Schema Class Generator failed to generate classes.
    oracle.xml.parser.schema.XSDException: Invalid attribute 'name' in
    element 'element'

    Your schema is not a valid XML Schema. Please check up with the syntax.
    Thanks.

  • Parser converting java source file

    I want to build a parser, which reads a java source and adds stubs at the start and end of a method, which might be for a public/protected/private method.
    This public/protected/private keyowrd , and source file will be passed as command line arguments to the parser.
    The generated output java source file should be similar to input source file with stubs.
    For example , we have a java source file( A.java) file as specified below
    class A{
         public m1(int m1_a, int m1_b){  }
         protected m2(int m2_x, int m2_y){ }
         private m3(int m3_p, int m3_q) {  }
    parser public A.java;
    after parsing it should generate output source file as A.JAVA as specified below
    class A{
         public m1(int m1_a, int m1_b)
    {  System.out.println(" start of "A:m1"" +  time: +"parameters:" +" a="+a ," b="+b)
         System.out.println(" End of "A:m1"" + time: +"parameters:" +" a="+a ," b="+b)
         protected m2(int m2_x, int m2_y){ }
         private m3(int m3_p, int m3_q) {  }
    Are there any tools , example programs , tips on the above problem .
    Anticipating help at the earliest

    HI dcminter,
    I am not talking about performance tuning,
    I need to build a program ( tool) which add System.out.println() statements as specified above for specific methods ( which might be public/private/protected ) which will be passed to the parser along with the java source text file.
    This program(tool)should only convert from one java source text file (A.java) to another java source text (A.JAVA) file , by adding the extra System.out.println() statements.
    Please help in this regard about any sample or tool or tips in solving.
    Awaiting for ur reply
    --gvr123                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Translate java source file

    Dear Friends,
    Does anybody know how to translate java sources file and get all the info from it.
    Like i want to write a parser and want to extract its details and store in datastructures.
    Any similar examples present or any suggessions please inform.
    Thanks in advance.

    there is a tool called javacc which generates parsing code. You can also google for "javacc grammar repository" to find a java grammer you can pick up and start using

  • Encoding of java source files

    I've sucesfully compiled java source files (*.java files) over a lot of different encodings (ANSI, Unicode, UTF8, etc). My IDE (Eclipse) has Cp1252 as default on WIndows OS.
    There is an 'official' encoding for source files ?

    Short answer is Unicode -but that's not enough.
    From Java Language Specification:
    "Except for comments (�3.7), identifiers, and the contents of character and string literals (�3.10.4, �3.10.5), all input elements (�3.5) in a program are formed only from ASCII characters (or Unicode escapes (�3.3) which result in ASCII characters). ASCII (ANSI X3.4) is the American Standard Code for Information Interchange. The first 128 characters of the Unicode character encoding are the ASCII characters."
    There's more that applies, I'll not quote it, read chapter 3 of JLS for details.
    http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html

  • Do we have to separate java source files and class files after compiled..

    Hi,
    I really confussed with this:
    I have compiled java source files into a package and tried to use but the classes can not be found. Should I separate class and source files after compiled with packages names. I hope you understand what i mean.
    Thank you
    So Jag

    You can choose to separate the source files or not. It sounds like your problem has to do with Classpath and packages.
    If the file c:\base\compute\engine\mysourcefile.java starts with the statement "package engine;" then the fully qualified name of the class is is engine.mysourcefile. If the file c:\base\compute\client\mysourcefile.java starts with the statement "package client;" then its fully qualified name is client.mysourcefile.
    In your source files, whenever you refer to a class from another class, the compiler needs the fully qualified class name. You can either import the class or use the fully qualified name. In order for the compiler to find the class, the c:\base\compute directory must be in the Classpath (assuming the package definitions from above).
    Finally, to launch an application given the above, the command would be "java client.mysourcefile" assuming the main method is in client.mysourcefile.

  • J2EE BluePrints: correct location for common Java source files

    I have a set of Java source files that are common between multiple J2EE applications.
    Within the J2EE package hierarchy, what is the correct location for these files?
    Also, is there a typical package name that common Java source files are grouped under?

    HI,
    There is no standard place. In the blueprints project conventons
    http://java.sun.com/blueprints/code/projectconventions.html it has a place called components/ which would contain shared components like EJBs and other components that could be shared across applications. the package naming would be reflected in that, like com.sun.blueprints.application1. and com.sun.blueprints.application2. and com.sun.blueprints.common.*
    Generally you could put a directory at the same level as the apps (not inside an app's directory structure) and maybe called common/ or shared/ . This common code could be built separtely and into a binary library or jar that you just include in the other applicatons, in the same way you would include some external library jar that you got somewhere and keep in your workspace and your apps use. The packaging of common code is similiar to the packaging of different applications and shared components.
    hth,
    Sean

  • XML to Java source files

    Hi,
    I need to create classes and interfaces for certain elements in my node.xml ( along with a node.dtd).
    In my node.xml I have the following element:
    <exception name="XXNotLockedException">
    <description>The xxxx to be tested was not in administrative state LOCKED.</description>
    <exceptionParameter name="message">
    <dataType>
    <string/>
    </dataType>
    </exceptionParameter>
    </exception>
    from this I want to generate a java source file like below.
    Is it a possible and good way to do it? Or is it the old SAX with events that shall be used?
    I have managed to generate java files but they are only the default ones.
    All help appreciated from more experienced programmers.
    //Mikael
    Source file
    package se.company.xxx.bcm.iface;
    public class XXNotLockedException
    extends se.company.xxframework.XXAccessException
    * Constructor
    public XXNotLockedException()
    super("XXNotLocked");

    I would say using XSLT would be easier to understand than a SAX events program. And more flexible, too, if your requirements changed.

  • Windows Easy Transfer (WET) Issues with External Hard Drive - "Can't read from the source file or disk"

    I work for Office Depot, in the tech department. Basically, one of our associates was supposed to do a data backup, and re-install Windows 7, then transfer the files back. He used Windows Easy Transfer and compacted everything into a 163 GB file. 
    Now comes the hard part. When we try to put it back on his computer ((drag-and-drop to the desktop) which has been wiped back to factory settings using the recovery partition), it stops at 79.5 GB remaining (you know how it doesn't give you a % of completion,
    it just shows how many GB are remaining) and then says "Can't read from the source file or disk" and gives you an option to try again, or cancel. It gets hung up on the same point each time.
    Normally, this wouldn't be a huge issue, but the contents on the drive are his wife's architect blueprints and interior design stuff, along with wedding photos, etc, which are the only copies they have. On top of those, they have court documents and other
    important files that we are unable to access now.
    I wasn't involved with this transfer, so I'm trying to clean up the mess as best I can. I remembered that the customer's wife was Russian, and had some files typed with a Russian keyboard, so on and so forth. I wonder if that's the issue? If not, I really
    have no idea how to manually extract things from a ".mig" file, or how to diagnose what area is potentially corrupted.
    In light of this situation, we tried using "Recuva" to recover the files post-wipe, but everything was corrupted or unable to be opened, and it also extracted and recovered all of the "useless" photos, such as the skype logos, up and
    down arrows for browsers, etc (it was 160,000+ photos).
    Trying to avoid a potential lawsuit, unhappy customer, and costing the company lots of money to see if professionals can get into this external hard drive.
    Other relevant information:
    We used a Toshiba 500 GB (465 GB) external hard drive.
    Customer's computer is an HP Pavilion P6000 Series (Model No. p6520y) running Windows 7 Home Premium 64-bit Service Pack 1.
    Any other information that is needed can be provided, thanks in advance, and hopefully we can find a solution to this issue quickly!
    -John

    I think there's a lack of understanding somewhere.
    "If you even can't start the process, please unplug it from your new PC. Then head back to your new computer and plug
    the external drive back in to your new computer. "
    Unplug from new, head back to new, plug it back in? That doesn't make much sense! Haha.
    I knew what you meant though, somewhat. When I search through the drives after clicking yes (Has windows easy transfer
    already saved your files blah blah blah) I click on the transfer file and it says "Windows Easy Transfer could not open the file".
    Rather than drag-and-drop the file to the desktop, I now tried to double-click on the file itself while it was plugged
    into the computer. It opened, and it started transferring until it was about 70% completed, and then an error popped up saying "WET can't open the easy transfer file, make sure your USB device is plugged in or check your internet connection". 
    I checked, and the USB hard drive's light wasn't on. Now, I unplug it and plug it back in, and the light comes back on,
    so I click Retry, and it resets the bar back to nothing and says "Transfer time: 1 minute".
    Rather than continue trying, I clicked "Cancel" instead of Retry, and it says "Your transfer did not complete successfully."
    It says to click "view report" for more information, but there's no "view report button".
    At the moment, I am scanning the External Drive for bad sectors using the check disk tool in properties. It's frozen
    at "0 USN bytes processed".

  • Getting all the members (variables, methods AND method bodies) of a java source file

    For a project I want to programmatically get access to the members of java source file (member variables, methods etc) as well as to the source code of those members. My question is what is the best method for this? So far I have found the following methods:
    Use AST's provided by the Java Source API and Java Tree API, as discussed in the following posts:
    http://today.java.net/pub/a/today/2008/04/10/source-code-analysis-using-java-6-compiler-apis.html
    http://weblogs.java.net/blog/timboudreau/archive/2008/02/see_java_code_t.html
    http://netbeans.dzone.com/announcements/new-class-visualization-module
    This has the disadvantage that the classes actually have to be compilable. When I look at the Netbeans Navigator view however, it provides me with a nicely formatted UI list, regardless of the "compilable" state of the class.
    Thus I started looking at how to do this... The answer appears to be through the use of tools such as JavaCC: https://javacc.dev.java.net/
    ANTLR: http://www.antlr.org/
    which are lexers and parsers of source code. However, since the Navigator panel already does this, couldn't I use part of this code to get me the list of variables and methods in a source file? Does the Navigator API help in this regard?
    Another route seems to be through tools such as
    BeautyJ: http://beautyj.berlios.de/
    which run on top of JavaCC if I am correct, and which has the ability to provide a clean view on your java code (or an XML view). However, BeautyJ does not seem to be too actively developed, and is only j2se1.4 compatible.
    I hope someone can shed a light on the best way to go about what I want to achieve. Somebody already doing this?
    (I crossposted on the Netbeans forums too, hope this is OK...)

    I'm currently developing a LaTeX editor(MDI) and I do the same thing, but I don't know what exactly do you need.

Maybe you are looking for

  • GL account Posting.

    Hi gurus, I  am getting GL account file from third party.In that file I have to check the GL account and line Items and post to FB01 through Inbound IDOC. In that file I have to check the GL account line items. 1. Suppose the account is not balanced

  • Crashes converting .txt

    Windows 7 Ultimate 64-bit Adobe Acrobat Pro 9.4.0 (Fresh new install - have rebooted a couple of times since) Can combine .jpg to a PDF. (From the right click menu of selected objects in Windows Explorer) As soon as I try to include a .txt file in th

  • CS6 in combination with FileMaker - Pictures are printed to big but shown on screen correct size

    I'm using FileMaker since more than 10 years together with pictures made in PS (since version CS2) saved as .jpg / 100dpi it always worked perfect! Now I got CS6 and any new picture is shown in the correct size but when I print it out of FM it gets m

  • Tables containing item status procedure used in sales documents

    Hello experts, I need make a query in order to know the status procedure used into items of sales documents. Example: In some items of sales orders I have status procedure CRMORD_I and in some items I have Z_ORDR_I. I need make a query in order to cl

  • If win 7 64 bit will not support Firefox 10 why offer it

    I have just read that you will not support 64 bit win 7 O/s so why am I being offered it twice now to be honest. you are correct this M/C is 32 bit but not my other one which is 64 bit