My JAR file is not working properly!!!

Hi everyone,
I made an application that has a GUI (window). I converted it into a JAR file so I can send it to a friend by email. Then she can run it to generate the output. First, the user has to select a destination to save the .txt file (using JFileChooser). Then enters the inputs (using JTextFields). Clicks "Run" button (Results will be calculated and copied to the file). A Message will appear indicating that the results are copied. The problem is that when I run the application in the IDE (Eclipse) it works fine. But when I convert it into JAR, The moment I click the "Run" button, suddenly the window closes. Please HELP???
Thank you

DrClap wrote:
Eng.Sh_2004 wrote:
Sorry guys, but i would like to make things clearer, As I mentioned earlier, What i'm doing is the following: 1) Using the Jfilechooser, save the results into a filename.txt file _[main class in the manifest file (class for the GUI) ]._ 2) Click "run" to write the data to the created file in step 1 [_another class is used to write to file_]. I have a feeling that the problem is related to the manifest main class. What do you think guys?I think your description of the problem is very bad. And I think your idea of making wild guesses is a bad way of diagnosing problems.
First of all. A JFileChooser does not save anything. It just allows the user to select a file to be saved to. So if you thought that the first step was writing anything or creating any file, you're probably wrong. But examining the code would help you understand.
Second, if you're having problems because one class chooses the file name and a second class writes data to it, then you're probably running into the basic beginner problem we see around here all the time of how to communicate data between objects. Again, examining the code might help.
Third, you need to understand what is writing that error message. Examining the code would help there too.
So: stop guessing. Look at the code.I'm still New To Java that's why i find difficulty in problems diagnosis. Regarding the JAR problem, as you mentioned, I used JFileChooser to select a file and (copying data) is the other part. So I will look at the code again.
Edited by: Eng.Sh_2004 on Aug 26, 2010 1:10 PM

Similar Messages

  • .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 ?

  • Jar file is not working

    Hi,
    I have an Applet packed in a JAR file. It works very well in my local site, but when I upload it to internet it throws a java.lang.ClassNotFoundException: nibbly
    Of course I've checked names, cases, files are in the same directory.
    The html code is very simple:
    <APPLET ARCHIVE="nibbly.jar" CODE="nibbly.class"
    WIDTH=402 HEIGHT=350>
    </APPLET>
    Any help or advice would be appreciated.
    Thank you

    you can see the error in
    www.magnino.terra.cl/arch/nibbly.html
    I will check the "binary mode" of my FTP
    the nibbly.jar is in the same directory of the nibbly.html page
    thank you
    Luis

  • Jar file is not working after deleting all packages from the same directory

    hello
    i have created a jar file named as server.jar in the same directory in which i have all the packages(for which i have created this jar file).This jar file was working correctly when i had all the packages in the same directory.But after deleting all the packages from the same working directory, this jar file is neither working nor giving any error message..
    Please tell me what may be the reason???
    thanks in advanced

    hello
    i have created a jar file named as server.jar in the same directory in which i have all the packages(for which i have created this jar file).This jar file was working correctly when i had all the packages in the same directory.But after deleting all the packages from the same working directory, this jar file is neither working nor giving any error message..
    Please tell me what may be the reason???
    thanks in advanced

  • File Monitor - Not working properly on SMB file share

    The "File Monitor" does not trigger on SMB file share, i think this might be a bug.
    I have tried the same "File Monitor" on a windows share, and it works like intended. However, when I use the same runbook on a Solaris SMB share, it does not trigger properly. It triggers when I delete or rename a file, but not any thing else (like
    create, changed, etc) I have turned all the triggers on just to see what actually makes it trigger...
    I'm using specified authentication (domain user and password)
    The SMB folder is shared on a Solaris (SunOS 5.10).
    Can anyone confirm that they also have this problem?
    Is there a patch to fix this? Thanks.

    Can someone please verify that they also have this problem?
    Thanks.

  • .jar file suddenly not working

    I have some minimal experience working with .jar files, but I am baffled here.
    Recently, the jar file for one of my programs stopped working. I had just made a change to my main class, so i repackaged the jar. Now it says "Can't find main class" when I try to run it. It will only work if I add the line
    Class-Path: . (there is a period there)
    to my manifest.
    This would be fine, but I want to use exe4j to make it into a Windows executable. exe4j must do something where it does not honor the mainifest settings, because the executable gives out a "can't find main class" error no matter what.
    What has happened? It is only an issue with this program, i have repackaged several others to test, and they work without the "Class-Path" workaround. I'm pretty sure that it's not something in the nature of the program itself, because it worked eariler, and my only change was a small one (the text of a few JLabels).
    I have made sure that my main class is in the root of my jar file, and I have the Main-Class attribute correctly set in my manifest. The program runs fine outside the jar, but displays this odd behavior only when "jarred".
    Any help would be greatly appreciated.

    also, it's only the one class that's affected.
    I tried setting the Main-Class to other classes in the jar, and that worked fine. When I tried to make a workaround, making one of the other classes' main call the one I wanted, i got a "fatal exception" error. I'm pretty sure it still couldn't find the file.

  • Help -- Trying to create JAR file but not working

    Hi everyone
    I have created a rather noddy Java program that consists of 4 JComboBox's and 1 JButton on a JFrame.
    When the button is clicked a text file is generate with the options that have been selected.
    There are severial files that the program uses for this:
    gcc.java
    OutToFile.java
    gccConfirm.java
    MyNewWindow.java
    main.java
    I am using Jcreator and so must use the command line to create the Jar file.
    I have never done a jar file before so I did an example with a hello world program and got it working now problem. I did the same for this program and the JAR file is generated without error. I double click on the JAR file to run the application, but nothing happens. I can see the application running in memory but nothing loads on the screen. However if I run it from the command line using Java -jar gcc.jar then everything is ok.
    can anyone help me here?
    thanks in advance

    If you run you .jar from the command line (a shell in unix speak) there
    already is a console where your java program can send it's System.out
    stuff. Right click on your .jar and select 'properties' (or similar). Note
    that your .jar is run by 'javaw'. This executable is similar to the 'java'
    executable except that it doesn't open a console for you. Change the
    'javaw' command to 'java' and voila, there's your console again.
    kind regards,
    Jos

  • Executing jar file does not work

    i am using net beans 4.1, jdk 1.4.2_09 and jre 5.0 update 4.
    i create a jar in netbeans, exit netbeans, go to the directory where the jar has been placed and double click the jar file to run it. when i do so i get an hour glass momentarily and then nothing. the program does not execute. i hope i am not missing something very basic here. i assume i can run the program by double clicking the jar file ....
    i have checked in netbeans to insure that all classes are in the jar, the manifest looks good, etc, etc. it looks like all the pieces of the jar are in place but the program will not run. please help.
    thanks,
    dave ...

    Directory of C:\JAVA\PROJECTS\DIST
    10/04/2005 10:09 AM <DIR> .
    10/04/2005 10:09 AM <DIR> ..
    10/04/2005 10:09 AM 25,203 gift_email.jar
    1 File(s) 25,203 bytes
    2 Dir(s) 124,456,144,896 bytes free
    C:\JAVA\PROJECTS\DIST>echo %CLASSPATH%
    c:\java\projects\dist;c:\Program Files\netbeans-4.1\ide5\modules\ext
    C:\JAVA\PROJECTS\DIST>java -jar gift_email.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: org/netbeans/lib/awtextra/AbsoluteLayout
    at giftrecpt.email.gift_email_gui.initComponents(gift_email_gui.java:38)
    at giftrecpt.email.gift_email_gui.<init>(gift_email_gui.java:24)
    at giftrecpt.email.gift_email_gui.main(gift_email_gui.java:142)
    C:\JAVA\PROJECTS\DIST>
    i added the location of the absolutelayout method to the classpath but still get the error. i also included this same reference in netbeans to the project under run-time libraries. so it seems that i have added the necesary references but still no luck. what could i be missing? the manifest makes no mention of class path. here it is below:
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.6.2
    Created-By: 1.4.2_09-b05 (Sun Microsystems Inc.)
    Main-Class: giftrecpt.email.gift_email_gui
    X-COMMENT: Main-Class will be added automatically by build
    thanks,
    dave ...

  • File.lastModified() not working properly.

    Hi,
    I need to check if the file is modified or not.So Iam using the following code.
    public void testLastModified() {
              for(int i =1 ;i < 10 ;i++){
              String filePath = "C:" + File.separator + "test1.rtf";
              File test1 = new File(filePath);
              if (test1.exists()) {
                   System.out.println("File exits");
                   if (test1.canRead()) {
                        System.out.println("Can read file");
                        if (test1.canWrite()) {
                             System.out.println("can write file");
                             long time = test1.lastModified();
                             System.out.println("last modified:" + time);
                             try {
                                  this.sleep(1000);
                             } catch (InterruptedException e) {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
                             System.out.println("wait completed");
                             System.out.println("last modified:" + test1.lastModified());
    while the thread is in sleep state for 1000 ms iam openning and modifying the file.But not saving it.
    The code prints the same modified time as that of the intial modified time.
    So can't we determine last modified time without saving the file.
    Thanks in advance.

    The question doesn't make any sense at all. If you haven't saved the modifications yet, the file hasn't been modified yet, so how could the last-modified date & time change? Why should it change?
    Having said that, some platforms don't modify this attribute until the file is closed.

  • File Dependency not working properly

    Hi,
    In our project we have a job group which will move a set of file from one directory to another directory. The first job in that group will be run only when a file with an extension "ind" is present in the source directory, i.e the dependency is set to a file with extension *.ind(Please see attached screeshot for reference).
    But when we run the job the dependency is not being satisfied even though the file is present in the source directory.
    What could be the reason for this?
    Note: If I overide the job, then the files are properly griing moved. But since this is automated, the job run must be based on the dependency we have set.

    This sounds like the runtime user of the job is a different account than used by the agent.
    File Dependencies and File Events are evaluated by the agent process.  This means the account running the agent service must have access to the file.
    When the job runs it uses the runtime user.  If the runtime user is different account than the agent account you can encounter the problem you describe.
    If this is a Windows agent running as a Local System account, the agent will only have access to files local to the server.  So if the file is on another server the agent will not have access to it.
    If this isn't your issue, could you provide details about the agent (windows/unix), file location (local to agent/UNC path), and whether the agent running the job is the same as the agent being used to evaluate the file dependency.
    Thanks.

  • File Sync not working properly

    Hopefully someone else has come across this problem. I'll try to set the stage here: I'm running D.W. CS6 and manage about a dozen Web Sites that have been up & running for years without ever seeing this problem.
    When I update a file i.e. contactus.html on my local server then try to sync it with remote server I get But the local file has changed...If I hit YES on the 'No Sync necessary' I get No files listed in the next screen,
    I can connect & see the remote files but can not Sync to it nor manually update it. I tried recreating the Site Cache but that did not help. I also deleted the dwsync.xml on local & restarted D,W. Same results.
    I guess I could delete the Site Definition & start over but I am not sure that would remedy my situation.
    Please assist, Thanks in advance. Pat 

    Synchronization in DW has always seemed to have random issues for me.
    To be honest, I just stopped using it all together and went with...
    Right click the root folder in the Files window
    Choose Select > Recently Modified
    Set the Days field to 1
    That will highlight anything changed in the last day according to DW itself (no server interaction required)
    Put the highlighted files
    You'll end up uploading a couple extra files, to be sure, but it's a lot faster than trying to find them by hand.

  • File Sharing not working properly on app

    Hello,
    My group has been developing an app that will run on an iPad for a company and the app needs to add or edit documents (in pdf format) to the app through itunes. We've implemented UIFileSharingEnabled in the info.plist and the app appears on iTunes that it can support file sharing. Now the problem is when we add files to the app, the files don't appear in the app itself and we've searched trying to find out what could be causing this but we're not sure what's going on.

    What code have you written in the iPad app to allow the files added via iTunes to 'appear' there?

  • File.delete() not working properly

    Hi Forum!!
    I am trying with the below code :
    File file = new file("path");
    try{
    if(file.exists())
    System.+gc+();
    file.delete();
    System.+out+.println("Control in delete trx file after deletion"+ file.exists());
    }catch(SecurityException se){
    String msg= "Delete trx file if 3gttz file created : IO Problems";
    Log.+error+(msg, se);
    }file.exists() returns false But I when I check file, it still exhists with content 0 bytes .
    Is there a way to remove the entire file from the directory rather than deleting only the
    contents ? Need not to tell I did my initial search to solve the problem.
    Thanks
    Edited by: jagabandhu on Feb 10, 2009 1:09 PM

    georgemc wrote:
    PhHein wrote:
    corlettk wrote:
    We can't all be rocket surgeons, either ;-)Heart scientist is the word you're looking for.Or rockin' sturgeons. A (marginally) cooler - albeit fictional - alternative to this abominationFrom a crazy drunk:
    A "bottle in front of me" is better than a "frontal lobotomy"!
    (Sound out those two quoted strings.)

  • Why is my Acer "Ab Files" program not working properly when I download it to my Acer Aspire One?

    Hello there, Im having an issue with trying to download Acers Ab files that works with the apps for Iphone. When I do download it and I click on it, my screen goes black for a second and then everything on my screen gets huge like its in SAFE MODE. I've tried to uninstall it and it keeps doing the same darn thing. I've checked for recent updates for windows and spy and malware and any corrupt files using a program that detects and fixes them. It comes up clean. This program used to work on my computer and now it doesn't. So far, I think its the only one that works convienently using wireless, unless theres another app that does the same. Anyone have this problem? Thanks....

    Charliewhitepaw,
    When you say this program used to work on your computer, what has changed since then? Have you attempted to go back (system restore) to when it worked to see if that resolves the issue?

  • Jar file can not work well

    Hi All,
    an error: base.ejb.command.CommandException: crypto.ITrustConfig.isAllowRecallSecurityQuestionAndAnswerEmpty()Z
    throwed by the tomcat server.But the source code does not have a character "Z" followed by the method. Any body encounter the same problem or give me some advice?

    What is the return type?, and how is toString implemented for the class?

Maybe you are looking for

  • Calling procedures multiple times passing rum time parameters

    hii, i ve this small prob with my procedure..my proc is CREATE or replace PROCEDURE sad(star_val number,dept_id number) IS BEGIN update dept set star=star_val where department_id=dept_id; END; and i call this proc using a loop and give the values at

  • Malicious TornTV add-on continously returning after being disabled- How do I fix this?

    I've been having issues with an add-on to my browser by TornTV that continuously returns after being disabled via the link provided on the ads it invasively opens and via the Add-on Toolbar. I've done the process many times and even sent a formal req

  • CS4 design standard Etudiant

    Bonjour, Mon fils est entré cette année en 1ère année BAC PRO Communication graphique (PAO). Le lycée où il est utilise une version CS3, ils pensent passer en version CS4 dans le courant de l'année. La version proposé sur Adobe Store est la CS5.5.Il

  • Question on Javascript

    Can someone please tell me if I can save the user input data to a file using Javascript. Also, if i can read the data from a file in javascript? Thanks for your time and effort

  • Adobe, please make a formal statement about "free" CS2

    Folks, we have heard the whole gambit of ideas and discussions concerning Adobe's "giveaway" of CS2. To my knowledge, there has only ever been ONE SINGLE post about CS2 NOT being released for free - and that post was in a FORUM. InDesign Secrets pick