.jar netbeans

hello all,
I created a jar file using netbeans put in a classpath for a database driver (derby.jar). There are also 8 classes in this jar file, i specified which main should start everything is working perfectly. But some of the classes access audio and images in the jar file, but i get an exception saying that i am missing these files but they are in the jar file! Anyone know why?
This is how the class access these files:
AudioStream sound1 = new AudioStream(new FileInputStream("Test.wav"));And this is the exception:
Exception in thread "main" java.io.FileNotFoundException: Test.wav (No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:106)
        at java.io.FileInputStream.<init>(FileInputStream.java:66)
        at Splash2.sound(Splash2.java:89)
        at Splash2.<init>(Splash2.java:40)
        at Splash2.main(Splash2.java:124)Will appreciate any help since i really need to get this to work.
Thanks all

I have had this problem before also, the way i got it to work was using:
AudioClip sound1 = Applet.newAudioClip(this.getClass().getClassLoader().getResource("SomeSoundFile.wav"));
//It also works for getting images out of a jar file:
ImageIcon imgicon = new ImageIcon(this.getClass().getClassLoader().getResource("SomeImage.gif") );
Image img1 = imgicon.getImage();Calling this.getClass().getClassLoader().getResource("SomeImage.gif") returns a java.net.URL to the image in your jar file, then you need to call something that can accept a URL and get an image out of it (for example, I used ImageIcon for simplicity). (Note that you need to call it from an instantiated class, and not your main method, you would most likely make this call in a media loader class or something)
The actual filename you submit as the getResource string is the path to the resource from the root jar directory, so if you had an image folder, you would just need to use something like "images/SomeImage.gif"
Good luck, I hope this helps

Similar Messages

  • Need to download latest jstl jar - netbeans problems

    have a problem with the formatDate func: "attribute value does not accept any expressions".
    Another post says he modified the fmt func within the tld. Changed <rtexprvalue>false</rtexprvalue> to true and it started working since it was supposed to be true to begin with.
    Catch is I'm using the standard jstl 1.1 lib from within Netbeans 5.0 and I'm unable to find the file to change it.
    Hence was thinking that if I could download the jstl jar separately, then I could fiddle with it (if it had the same bug) and then import it into netbeans quite easily.
    any ideas ?
    ciao, bhishma

    Thanks evnafets, You are correct. I downloaded the apache implementation and there it clearly had the /jsp added in the 'getting started' html page and when I tried it, it works.
    The pages I was referring to for the format tld did not have the /jsp in front. I wonder if it truly worked for them.
    http://www.onjava.com/pub/a/onjava/2002/09/11/jstl2.html
    http://www.sitepoint.com/article/java-standard-tag-library/3
    This is what threw me off.
    So at this point I'm assuming that the default sun implementation present in 1.5 (which my netbeans is using) also works, but I've already switched to apache so I'm not retesting for that.
    Will do so in the next few days when I have to setup the same on my friends comp.
    Thanks for your help.
    Ciao.

  • Executable JAR containing images doesn't load them

    I'm using Netbeans 4.0 for developping a Java Application. This application is composed of 3 packages:
    - daemonexplorerv10: which contains the main class.
    - GUI: which contains classes I use to create the GUI of the application.
    - images: which contains GIF and PNG images used by the application. It also contains a class named ImageLoader which is used to load the images contained in the package. I will detail this class later.
    My main class, named Main.java, simply lauches the main JFrame of the application GUI. Here is the code of it's main method:
    public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    MainFrame.createAndShowGUI();
        }In the GUI package, I created a class named MainFrame which extends JFrame and is the main frame of my application GUI. Here is the code of it's method createAndShowGUI:
        public static void createAndShowGUI() {
            //Suggest that the L&F (rather than the system)
            //decorate all windows.  This must be invoked before
            //creating the JFrame.  Native look and feels will
            //ignore this hint.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            MainFrame main_frame = new MainFrame(main_frame_title);
            main_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Display the window.
            main_frame.pack();
            main_frame.setVisible(true);
        }And here is the beginning of the code of it's constructor:
        public MainFrame(String title) {
            super(title);
            ImageLoader il = ImageLoader.getSingleton();
            ImageIcon application_icon = il.loadImage("application_icon.png");
            if (application_icon != null) {
                this.setIconImage(application_icon.getImage());
            else {
                System.out.println("Error - application_icon could not be loaded");
    ...As you see, MainFrame uses ImageLoader so as to customize the frame icon. ImageLoader follows the singleton pattern. It has a method called loadImage which returns an IconImage for a given image name. Here is the code of this method:
        public ImageIcon loadImage(String image_name) {
            ClassLoader cldr = this.getClass().getClassLoader();
            URL image_url = cldr.getResource("\\images\\"+image_name);
            if (image_url != null) {
                return new ImageIcon(image_url);
            else {
                return null;
        }For every image I want to use in my application, I use ImageLoader. It fetches the image thanks to the given name, provided that the image is placed in the package called images, or else the method loadImage returns null.
    So the MainFrame uses ImageLoader which fetches the image "application_icon.png" for the frame to set it as it's custom icon.
    My application runs perfectly well :)... as far as I run it through Netbeans launcher. But Netbeans also creates automatically an executable JAR file for each builded application. So I tried to lauch this JAR. Through this way, the application works, but all the images that should be loaded aren't!
    I unpacked the JAR so as to check if all the images are in it. Netbeans includes the images. Netbeans also creates a manifest file which seems perfectly correct.
    So I can't understand why my application runs without any images when I launch it through an executable JAR while it works fine (with all the images) when I lauch it through Netbeans.
    I checked many forums to find a solution. Using ImageIO doesn't or ToolKit doesn't solve the problem. It simply seems that the path of the package called images can't be found by the method getResource when this package is compressed in the JAR.
    P.S: I use J2SE Development Kit 5.0 and J2SE Runtime Environment 5.0.

    So ReinerP, I tried your code today in a little test application which has a single package containing two classes:
    - Main.java
    - JMainFrame.java
    Here is the code of Main.java:
    public class Main {
        /** Creates a new instance of Main */
        public Main() {
         * @param args the command line arguments
        public static void main(String[] args) {
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    //Suggest that the L&F (rather than the system)
                    //decorate all windows.  This must be invoked before
                    //creating the JFrame.  Native look and feels will
                    //ignore this hint.
                    JFrame.setDefaultLookAndFeelDecorated(true);
                    //Create and set up the window.
                    JMainFrame main_frame = new JMainFrame();
                    main_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    //Display the window.
                    main_frame.pack();
                    main_frame.setVisible(true);
    }And here is the code of JMainFrame.java:
    public class JMainFrame extends JFrame {
        /** Creates a new instance of JMainFrame */
        public JMainFrame() {
            super();
            //load and set icon
            URL imgURL = JMainFrame.class.getResource("icon.png");
            ImageIcon img = new ImageIcon(imgURL);
            setIconImage(img.getImage());
    }As you said, it works :). It works when I run it through Netbeans launcher, and it also works when I run it through the Executable JAR Netbeans generated during the building of the application.
    So I adapted the code of the application I was talking about in the first post of this topic. I modified the code of the method loadImage in ImageLoader.java:
    public ImageIcon loadImage(String image_name) {
    //not working in JAR:  ClassLoader cldr = this.getClass().getClassLoader();
    //not working in JAR:  URL image_url = cldr.getResource("\\images\\"+image_name);
            URL image_url = ImageLoader.class.getResource(image_name);
            if (image_url != null) {
                return new ImageIcon(image_url);
            else {
                return null;
        }And it works well. Thanks again. However, I still can't explain why the use of class loader isn't undertood by the executable JAR.

  • D-Light does not appear to be available

    I downloaded and installed the June 2007 build of SunStudio 12 Express and cannot find anything related to D-Light. My understanding is that it should be under the tools drop down.
    Here is the version string for SunStudio:
    Build 200704122300, SunStudio 20070501
    Did I somehow obtain the wrong version or do I need to take further steps to launch D-light?
    Thank you and regards,
    Marcus

    Marcus,
    This is strange that symbolic links are missed. As I understand you downloaded a
    complete image of "Sun Studio + D-Light", which includes NetBeans, which has
    these 4 symbolic links:
    netbeans-5.5.1/nb5.5/modules/com-sun-dlight.jar -> ../../../SUNWspro/contrib/dlight/com-sun-dlight.jar
    netbeans-5.5.1/nb5.5/modules/docs/com-sun-dlight.jar -> ../../../../SUNWspro/contrib/dlight/docs/com-sun-dlight.jar
    netbeans-5.5.1/nb5.5/update_tracking/com-sun-dlight.xml -> ../../../SUNWspro/contrib/dlight/update_tracking/com-sun-dlight.xml
    netbeans-5.5.1/nb5.5/config/Modules/com-sun-dlight.xml -> ../../../../SUNWspro/contrib/dlight/com-sun-dlight.xml
    They are not absolute, because netbeans-5.5.1 directory should be on the same level
    as SUNWspro directory, so the links use relative path:
    volga% ls
    SUNWspro netbeans-5.5.1
    volga% find netbeans-5.5.1 -name com-sun-dlight.jar
    netbeans-5.5.1/nb5.5/modules/docs/com-sun-dlight.jar
    netbeans-5.5.1/nb5.5/modules/com-sun-dlight.jar
    volga% find netbeans-5.5.1 -name com-sun-dlight.xml
    netbeans-5.5.1/nb5.5/update_tracking/com-sun-dlight.xml
    netbeans-5.5.1/nb5.5/config/Modules/com-sun-dlight.xml
    volga% ls -l netbeans-5.5.1/nb5.5/modules/docs/com-sun-dlight.jar
    lrwxrwxrwx 1 nikm staff 59 Jun 4 14:14 netbeans-5.5.1/nb5.5/modules/docs/com-sun-dlight.jar -> ../../../../SUNWspro/contrib/dlight/docs/com-sun-dlight.jar
    volga% ls -l netbeans-5.5.1/nb5.5/modules/com-sun-dlight.jar
    lrwxrwxrwx 1 nikm staff 51 Jun 4 14:14 netbeans-5.5.1/nb5.5/modules/com-sun-dlight.jar -> ../../../SUNWspro/contrib/dlight/com-sun-dlight.jar
    volga% ls -l netbeans-5.5.1/nb5.5/update_tracking/com-sun-dlight.xml
    lrwxrwxrwx 1 nikm staff 67 Jun 4 14:14 netbeans-5.5.1/nb5.5/update_tracking/com-sun-dlight.xml -> ../../../SUNWspro/contrib/dlight/update_tracking/com-sun-dlight.xml
    volga% ls -l netbeans-5.5.1/nb5.5/config/Modules/com-sun-dlight.xml
    lrwxrwxrwx 1 nikm staff 54 Jun 4 14:14 netbeans-5.5.1/nb5.5/config/Modules/com-sun-dlight.xml -> ../../../../SUNWspro/contrib/dlight/com-sun-dlight.xml
    You can create them manually, but it seems better to download the image again,
    and extract it.
    Thanks,
    Nik

  • From 5 to 4

    I've written a JSP/Servlet app with the newest netbeans IDE, got it fully working, only to discover that I now have to deploy it in a tomcat 4 server. And it has caused me a lot of problems, I have already placed the jstl 1.0 jar in tomcat, and changed the directive in the jsp page to be-
    <%@taglib uri="http://java.sun.com/jstl/core" prefix="c"%>but it still gave me this error:
    org.apache.jasper.JasperException: This absolute uri (http://java.sun.com/jstl/core) cannot be resolved in either web.xml or the jar files deployed with this application
         at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:105)
         at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:430)
         at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:154)............etc
    A second problem occured after I change to use the 1.0 jstl jar, netbeans complains when I tried to do a
    <c:if test="${param.hidedelisted ne null}"> checked</c:if>it says attribute test does not accept any expressions.
    Please give me a hand if anyone have tried to downgrade the code from tomcat 5 to tomcat 4. Thanks!

    Hi,
    You are changing the depreciation terms for an asset with APC value 10000, assuming it uses straight line depreciation method - the depreciaton amount per year for the next 5 years is 10000/5 = 2000 ( monthly = 2000/12 gives us 166.66667).
    when we change the asset useful life from 5 to 4, the depreciation recalculated 10000/4 = 2500 is the new depreciation amount for a fiscal year (monthly dep. value = 2500/12  = 208.333).
    SAP will post the recalculated amount in two different ways
    1) Smoothing
    2) Catch-up.
    In this first method, the depreciation posting program calculates the periodic depreciation to be posted by distributing the remaining depreciation to be posted equally over the remaining periods of the fiscal year. (refer tcode OAYR for sys settings)
    Example: depreciation posted for 5 periods starting from July to November = 833.32 , balance depreciation amount = 1166.68 for the current FY. Under the change in useful life the new depreciation amount is 208.33 + (difference in dep. amount posted for the last 5 periods to be equally spread across remaining 43 periods which equates 41.67*5 = 208.35, 208.35/43 = 4.845)
    i.e 208.33 + 4.845 = 213.175.
    Second method, SAP calculates depreciation in each period &  the amount of depreciation that must be posted from the start of the fiscal year to the current period. The depreciation already posted is then subtracted from this amount the system either makes up or reverses the difference in full during the next depreciation posting run using the catch-up method.
    Example: The balance depreciation amount of 208.35 is posted in the month of december along with the dep. amount of 208.33 = 416.68 and from next  month onwards the dep. amount will be 208.33.
    hope the explanation solves your query.
    regards
    govindarajan

  • Jws, adding libraries to deployed program

    Hello,
    I am having a problem and I cannot figure it out nor can I find anything online to help.
    I have a deployed JWS application. The application is changing in a way that requires new drivers and libraries to be added (Oralce JDBC drivers). I have a "launch.jnlp" file which points to a separate jnlp file for its libraries ("component.jnlp").
    To deploy the new program with the new libraries, I added a line to the component.jnlp file:
    Old File:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <jnlp codebase="http://www.ZREcp.com/TeamZRE/ZREToolsTest/dist/" href="component.jnlp" spec="1.0+">
        <information>
            <title>ZRETools</title>
            <vendor>ZRE Computer Programming, LLC</vendor>
            <homepage href=""/>
            <description>ZRETools</description>
            <description kind="short">ZRETools</description>
    <offline-allowed/>
    </information>
    <security>
    <all-permissions/>
    </security>
        <resources>
    <j2se version="1.5+"/>
        <jar href="lib/poi-3.5-FINAL-20090928.jar"/>
    <jar href="lib/jcalendar-1.3.3.jar"/>
    <jar href="lib/jfreechart-1.0.13.jar"/>
    <jar href="lib/jcommon-1.0.16.jar"/>
    <jar href="lib/AbsoluteLayout.jar"/>
    <jar href="lib/jaybird-full-2.1.6.jar"/>
    </resources>
        <component-desc/>
    </jnlp>new:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <jnlp codebase="http://www.ZREcp.com/TeamZRE/ZREToolsTest/dist/" href="component.jnlp" spec="1.0+">
        <information>
            <title>ZRETools</title>
            <vendor>ZRE Computer Programming, LLC</vendor>
            <homepage href=""/>
            <description>ZRETools</description>
            <description kind="short">ZRETools</description>
    <offline-allowed/>
    </information>
    <security>
    <all-permissions/>
    </security>
        <resources>
    <j2se version="1.5+"/>
        <jar href="lib/poi-3.5-FINAL-20090928.jar"/>
    <jar href="lib/jcalendar-1.3.3.jar"/>
    <jar href="lib/jfreechart-1.0.13.jar"/>
    <jar href="lib/jcommon-1.0.16.jar"/>
    <jar href="lib/AbsoluteLayout.jar"/>
    <jar href="lib/ojdbc6.jar"/>          <---------------- New Line
    <jar href="lib/jaybird-full-2.1.6.jar"/>
    </resources>
        <component-desc/>
    </jnlp>After rebuilding the code and re-signing the jars (Netbeans), I uploaded the new jars to my site, ran the program on a remote test-environment, but it did not download the new jar (ojdbc6.jar). I have not modified the program to use the Oracle-based functions yet but that won't work anyways unless the program downloads the new libraries.
    I have a sneaking suspicion if I were to manually edit the DEPLOYED jnlp file then it would download the library, but the program is distributed and I am not able to manually edit everyone's jnlp files.
    How do you get a deployed JWS program to download new libraries? This seems like it should be easy.
    Thank you for your help.

    BTW, this is my launch.jnlp file:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <jnlp codebase="http://www.ZREcp.com/TeamZRE/ZREToolsTest/dist/" href="launch.jnlp" spec="1.0+" version="1.2.0001">
        <information>
            <title>ZRETools</title>
            <vendor>ZRE Computer Programming, LLC</vendor>
            <homepage href=""/>
            <description>ZRETools</description>
            <description kind="short">ZRETools</description>
        <icon href="ZRESquareLogo.jpg" kind="default"/>
    <offline-allowed/>
    </information>
    <security>
    <all-permissions/>
    </security>
        <resources>
    <j2se version="1.5+"/>
    <jar eager="true" href="ZRETools_v1.2_test.jar" main="true"/>
    <extension name="component" href="component.jnlp"/>
    </resources>
        <application-desc main-class="firebirdprogram.Main">
        </application-desc>
    </jnlp>Thanks.

  • Application working under NetBeans but not as a *.jar file

    Hello,
    recently I found a little problem. I wrote application that shows all available ports in my computer. When I am running this applications under NetBeans it works with no problem - finds all available ports. Then I am building it to the *.jar file. Application is working with no problem but command:
    Enumeration PortIds = CommPortIdentifier.getPortIdentifiers();
    is not returning any identifiers - PortIds is empty.
    Anyone knows a solution for this type of problems? Thanks

    Hi Venkatesh,
    Few questions.
    1. What is your JDeveloper version? (Always better to post your JDev version along with the question, which would help us to help you better).
    2. Did you try adding webserviceclient.jar to the classpath? (Search in your JDev installation directory for the location of this jar file).
    -Arun

  • .jar file is not working properly :developed in NETBEANS

    Hi Gurus,
    i am using NETBEANS IDE 7.2.
    i am developing a project that interacts with databases 10g and COM ports of machine , these all processes are performed by .bat file which i am trying to run from jFramform , code works perfectly .bat file is also called perfectly when i run the project using F6 from the NETBEANS, for testing i placed some dialogue boxes on the form to test it ,
    but when i run executable .jar  file , form run successfully and dialogue box works perfectly but .bat file is not called by executable .jar file.
    this is how i call the .bat file...
      String filePath = "D:/pms/Libraries/portlib.bat";  
            try { 
              Process p = Runtime.getRuntime().exec(filePath); 
            } catch (Exception e) { 
                e.printStackTrace(); 
    and below is the contents of portlib.bat file
    java -jar "D:\SMS\SMS\dist\SMS.jar" 
    you must probably ask why i am calling a .jar file using .bat file .
    reason is that this .jar project sends message using GSM mobile , System.exit(); is compulsory to complete a job and then do the next one ,
    if i use the same file to execute this job it makes exit to entire the application (hope you can understand my logic).
    that's why i use extra .jar file in .bat file , when single job is completed .bat exits itself and new command is given.
    Problem is that code is working perfectly in NETBEANS when i run the project but when i run .jar then .bat file is not working  ,
    thanks.

    Thanks Sir ,
    You need to first test an example that works like the one in the article.
    There are plenty of other examples on the web - find one you like:
    http://javapapers.com/core-java/os-processes-using-java-processbuilder/
    I tried this one.
      try {
                ProcessBuilder dirProcess = new ProcessBuilder("D:/SMS/SMS/Send_message.bat");
                 File commands = new File("D:/SMS/SMS/Send_message.bat");
                 File dirOut = new File("C:/process/out.txt");
                 File dirErr = new File("C:/process/err.txt");
               dirProcess.redirectInput(commands);
                 dirProcess.redirectOutput(dirOut);
               dirProcess.redirectError(dirErr);
                 dirProcess.start();
            } catch (IOException ex) {
                Logger.getLogger(mainform.class.getName()).log(Level.SEVERE, null, ex);
    as instructed in the article i compiled  both the projects at same version or sources and libraries which is 1.7
    here is my version details
    C:\>javac -version
    javac 1.7.0_07
    C:\>java -version
    java version "1.7.0_07"
    Java(TM) SE Runtime Environment (build 1.7.0_07-b11)
    Java HotSpot(TM) Client VM (build 23.3-b01, mixed mode, sharing)
    inside the NETBEANS IDE c:\process\err.txt  remains empty and code works perfectly , but when I run executable .jar file( by double clicking on that file in dist directry) then c:\process\err.txt becomes full with this error text and there is no response from calling D:\SMS\SMS\send_message.bat
    here is the error text
    java.lang.UnsupportedClassVersionError: sms/SMSMAIN (Unsupported major.minor version 51.0)
      at java.lang.ClassLoader.defineClass0(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$100(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)
    Exception in thread "main"
    here is /SMS/SMS
    unknown source ?

  • Can Netbeans put a jar file In a jar file?

    I just went through the process of getting Eclipse to create a jar file that would execute from a command prompt using a plugin called fatjar :
    http://fjep.sourceforge.net/
    Details from other thread :http://forum.java.sun.com/thread.jspa?threadID=5219638&tstart=0
    I really would like to use netbeans but i now have the exact same problem trying to make a jar file in netbeans 5.5.1
    I am using a package from icaste.com It has a
    .dll file to put in the windows directory
    JCommSerial_3_0.jar file that contains all the classes
    I can compile and run a file in the IDE and it works fine
    The Jar file does not contain the classes so i get errors when running from command line.
    Here is the layout of my screen and result of run command in IDE
    http://www.acousticlights.com/netbeans.png
    What do I need to try?

    georgemc wrote:
    Why is everyone so obsessed with doing this? The gains are minimal and the problems numerousBecause we are new and don't understand how the java VM actually runs code and the error messages sent by the java machine are cryptic.
    My first attempt at using an external jar in a java program lead me to believe that all of the code for a java program would be in a jar file including external jar files, after all the JDK standard library has tons of jars in it so I assumed the external jar file would be linked (as most other programming compiler/linkers I have worked with in my top down programming life).
    I find out the answer is so simple that the external jar file could not be found by the VM running my jar file. Like I said, if the VM would have just gave me an error that it could not find a file on a specific directory i never would have perused the idea of jar in a jar (fatjar plugin for Eclipse for example)
    Really this is like getting into a race car and not knowing at what RPM to shift gears, sure you can press the pedal and make it go but if you don't understand how it works under the hood you are going to blow the engine if you keep it in first gear.
    I have read many posts on these errors, the reason is the error message is just not very descriptive of the original problem. If I try and open a database called xyz.dbf that has one field defined as lastname, in C for example, I would not give the error message "Lastname could not be found) when indeed the lastname could not be found but the reason it could not be found was because the database xyz.dbf could not be found. Further , adding to the error message that the system is looking for xyz.dbf on drive X- subdirectory -mydatabases would complete the error message and allow the user to fix the error. Just what is a non java programmer that is using my java program suppose to do with an Ecception Error in (main) bla bla bla... I know now I need to check for library files myself within my own java programs and give a better error message to the user before the java VM sends out it's cryptic message.
    Edited by: metron9 on Sep 25, 2007 11:00 AM

  • JAR Executable works in netbeans but not under Dos?

    Hi all,
    I have created a jar executable and it works fine in netbeans(it was not created in netbeans) but I can't get it to run on the command line. If I type java ClassName.MainClass it will run but not using the command java JarFile.jar or java -jar JarFile.jar
    Any help would be most appreciated.

    When creating the manifest file did you add a carriage return at the end of the manifest? e.g.
    Main-Class:Hello.class
    (carriage return here on new line)
    I think it runs into problems if you dont add a carriage return ( a new blank line after manifest).
    Hope this helps
    Riz

  • Program run in Netbeans but NOT running as jar file

    Dear all ,
    i hope any help in this problem.
    i am writing program to access parallel port i put next files :
    1. [ comm.jar + javax.comm.properties ] in
    [ C:\Program Files\Java\jdk1.6.0_18\lib ] and [ C:\Program Files\Java\jdk1.6.0_18\jre\lib ]
    2. [ win32com.dll ] in [ C:\WINDOWS\system32 ]
    when i run application in NetBeans IDE 6.8 work fine and every think is ok
    BUT when i produce jar file , generated jar file does not work [GUI appear but can not get ports on PC]
    - I try to set Environment Variable as next :
    CLASSPATH = .;C:\Program Files\Java\jdk1.6.0_18\lib\comm.jar
    also does not work
    any tip please ?
    Thanks in advance
    Nabil

    First of all, leave the lib and jre/lib directories of the JRE alone. Never ever touch them again. Remove any jars you have put there yourself, or better yet completely remove and reinstall the JRE to make sure you put it back in a correct state.
    After you do that, learn how to properly work with the classpath in both the IDE and the command line.
    Netbeans: you define the classpath by adding jars to the project (right click on the libraries node in the project tree to get the appropriate options).
    Command line: this depends on if you run a single class, or you invoke an executable jar.
    Single class: you use the -cp command line switch to define the classpath
    Executable jar: the jar itself defines the classpath in its META-INF/manifest.mf file. The -cp command line switch is ignored.
    Since you use Netbeans, you'll get an executable jar so make sure to learn how such a jar is structured.

  • How can I get a single jar file with NetBeans?

    How can I get a single jar file with NetBeans?
    When I create the project I get these files:
    dist/lib/libreria1.jar
    dist/lib/libreria2.jar
    dist/software.jar
    The libraries that have been imported to create the project are in separate folders:
    libreria1/libreria1.jar
    libreria2/libreria2.jar
    libreria1, libreria2, dist folders are all located inside the project folder.
    I added the following code to the build.xml:
    <target name="-post-jar">
    <jar jarfile="dist/software.jar">
    <zipfileset src="${dist.jar}" excludes="META-INF/*" />
    <zipfileset src="dist/lib/libreria1.jar" excludes="META-INF/*" />
    <zipfileset src="dist/lib/libreria2.jar" excludes="META-INF/*" />
    <manifest>
    <attribute name="Main-Class" value="pacco.classeprincipale"/>
    </manifest>
    </jar>
    </target>
    Of course there is also the project folder:
    src/pacco/classeprincipale.form
    src/pacco/classeprincipale.java
    Can you tell me what is wrong? The error message I get is as follows:
    C:...\build.xml:75: Problem creating jar: archive is not a ZIP archive BUILD FAILED (total time: 2 seconds)

    This is not a NetBeans forum, it is a JDeveloper forum. You might want to try http://forums.netbeans.org/. I also saw your other question - try looking in the New to Java forum: New To Java

  • NetBeans 5.5. + layout - how can I make a jar?

    1. I try to build my application.
    2. I've developed it in NetBeans 5.5
    3. I ve used form as a base for my GUI
    4. I've made application with help of GUIBuilder+some swing components I create dynamically during program execution.
    The problem:
    I can't make runnable JAR.
    When I try to launch project.jar form folder /dist I get message:
    "No main class found"
    I need to have these jars (they are in my project's library section:
    1.swing-layout-1.0.1.jar
    2. AbsoluteLayout.jar
    I found a solution:
    How can I package the swing-layout-version.jar library
    into my application JAR?
    Having developed your Swing application in Matisse (using the "Free Design" layout) you can
    package the required swing-layout-version.jar library inside your application JAR file.
    Requirements:
    &#9679; Standard Java project
    &#9679; Swing Layout Extensions library included in your project's classpath
    Open your project's build.xml from the Files tab and insert this:
    <target name="-post-jar">
    <jar update="true" destfile="${dist.jar}">
    <zipfileset src="${libs.swing-layout.classpath}"/>
    </jar>
    </target>
    Just press F11 to build your project as usual. This Ant target will bundle swing-layout.jar
    inside your distribution JAR file.
    You can adapt this Ant target to different requirements.
    So I've inserted this code into my build.xml
    Size of built project jar file increased.
    I try to lauch it and I get no message. Nothing happens.
    What else I have to do if I want to get distributable jar....?

    So I found a problem.
    Jar with main class created using GUIBuilder (NetBeans) doesn't launch.
    I use netbeans 5.5. + jdk 1.6.
    If I launch jar with frame-based main class - everything works.
    If I try to launch form-based main class - it doesn't work.
    I do not get any error message or something like that.
    What it can be?

  • How do I make a jar of netbeans (or anything big)?

    I was searching for a jar file of netbeans and instead found a different installation file per operating sytem. I am not complaining about this but I want to make a jar out of this (or another big problem) for the sake of learning how (a jar actually does have some benefits like bringing a program on a flash drive and making sure it works on all operating systems and CPU architectures). For small programs that I made myself, I basically have to make the class files in lets say directory "programDir" (without the quotes). I then make a file called x.mf and in it put "Main-class: MyClass" (without the quotes) followed by the "jar -cmf x.mf nameOfJarFile.jar *.class" command (without the quotes).
    I think the process is made more difficult when involving packages? So apart from the package issue, I think all I need to do is *1)* find the source code of lets say netbeans *2)* figure out which is the class with the main method in it.
    And yes, I have trouble finding the source code of netbeans! I downloaded the "OS-independent zip" and found a few .java files but it didn't seem to be the entire program!
    Any input would be greatly appreciated!
    Thanks in advance!

    s3a wrote:
    Why is it a bad example? To me it seems to be a very good one because like in Physics or ChemistryWell, we also do things in Poetry, but those have nothing to do with programming.
    I tried with a "toy application off my own" and I am having problems so maybe you can help me there? I have two java files each of which get compiled to class files and then converted to a jar correctly but once I add the line package SudokuPackage; at the top then the class files still get compiled but the jar file made is not one that works.
    When I remove package SudokuPackage; I have Main-class: SudokuDriverCode in the x.mf file but when I add package SudokuPackage; at the top of my java files and then compile (and use Main-class: SudokuPackage.SudokuDriverCode in the x.mf file), the jar does not work.
    How would I make programs with packages work?So what's the error message?
    Also package names are lowercase by tradition.
    Also, doesn't Netbeans have an install wizard? It's not distributed around as a regular jar.
    You need to get your basics straight before you start thinking of anything advanced.
    Edited by: Kayaman on Nov 7, 2010 8:07 PM

  • How  to include the inner classes in a jar file in netbeans ide

    Dear java friends
    how to say to netbeans ide that it has to include the
    inner classes in the jar file.
    (i have one single applet class
    with two inner classes that show up
    in the build/classes file but not in the jar).
    The applet works in the viewer but not
    in the browser (I believe because the
    xxx$yyy etc should be in the jar)
    willemjav

    First, please stop posting the same question multiple times:
    Duplicate of http://forum.java.sun.com/thread.jspa?threadID=5269782&messageID=10127496#10127496
    with an answer.
    Second, If your problem is that you can't do this in NetBeans, you need to post to somewhere that provides NetBeans support - like the NetBeans website's mailing list. These forums do not support NetBeans (or any other IDE) - they are Java language forums.

Maybe you are looking for