File.createTempFile naming problem

Hello All,
I am using WIN XP .I am creating a temporary file with the following code
File temporaryDll = File.createTempFile("abcd", ".dll");In the temp directory , though I marked in code deleteOnExit to temporaryDll , it creates files with abcd1234.dll , abcd1235.dll n so on .
The temp directory gets filled up with these number of dlls with diff suffix. Is there any mechanism or any code snippet will I get , to make sure that only one dll will get created n deleted after JVM termination.How can I check in the code , file already exists or not , because at every time it create new filename?
I have tried by deleting all abcdxxxx.dll from temp dir , I ran the code but wondered after watching in temp dir , abcd1234.dll file created instead abcd.dll .
Looking forward for help.
thanks
Ani

That's because you original files all end with a "2" and not the 4-digit number you want. "Original file#" takes the number at the end of the original file.
For example:
IMG_1234    >> "1234"
IMG_1234-2 >> "2"
Why are your originals all end with a "2"? Probably because toy imported some duplicate files and lightroom added "-2" to their name to avoid a filename collision.
Check you folders for duplicates.

Similar Messages

  • Problem with File.createTempFile

    I did File temp = File.createTempFile("cpyStats", ".xls");
    //                Delete temp file when program exits.
                   temp.deleteOnExit();
    System.out.println(temp.getName());But the result is : cpyStats30440.xls
    Why do it always have some number after my file name ?
    Anyone help me ?
    So stress because of it...

    Guys, if you don't want a random filename just don't
    use a method that creates a random filename.Please excuse my ignorance (new to java!). What's the easient way to do this/what method should I use?
    I simply need to create a new file with a precise name. This is because I need to retrieve the same file from a remote location later and so I can only do this if I know what it's filename was originally!
    n.b. The filenames I am generating will be unique.

  • File Export Renaming Problem

    I want to export collections of files from Lightoom.
    I want to rename the newely exported files, but I want to use the same file number suffix as the original file.
    I also want to embed the oringal file name in the metadata of the newly exported file.
    The problem is that, when I go into the File->Export dialog i.e. the "Filename Template Editor" the orginal  "file number suffix" is not showing up in what would be the newly created filename. The orginal file number suffix does not appear to be part of the metadata.
    The current filename on disk does however have the file number suffix as part of the name.
    However it does not seem possible to extract part of the current file name (i.e. the number suffix) on export.
    If I rename the files using a number sequence then adding or removing a file will change the sequence on subsequent exports of the collection.
    (Not something I want to do, since it would then be difficult to keep track of the images used originate the exported file, if I updated the collection.)
    Renaming all my original files is not a viable option since there are too many of them and different exported files may be in more than one collection.
    *Any suggestions as to how to get the file naming I want for the exported files, i.e. "placename-oringal file number suffix"?
    (Given the file number suffix is missing from the metadata)
    *Also I would like to include the existing file name in the metadata of any new file name.
    Any suggestions on how to automate this?

    John said:
    > Unless you check "minimize metadata", it should all be there.
    No I have not checked this box.
    > Second, if you rename your files just before you Export (and not in the Export dialog, but actually rename them by batch
    > so the LR name is changed) you'll be able to link them up to the originals much more easily.
    No this will not work.  My naming method is quite useful for me, but not useful for potential buyers.
    When I export collections I want to simplify the names.
    > Third, the rename editor is pretty flexible.
    Yes I know, usually it is sufficient, but in this case it does not do what I want.
    > Finally, all the metadata is there, and searching is much easier via it rather than a complex naming convention
    > (not that it's so complex, but getting there may be.
    Not sure I completely agree here.  My naming method works quite well for organising images and for processing and so on.
    Now since I have collections spanning multiple directories and so that I want to export the files with a simplified filename.
    I expected to be able to do this using the file name editing template.
    The BreezeBrowser renamer is much more flexible than the Lightroom filename template editor, so I may end up using that.
    However it will be messy and add a few extra steps. i.e. export to a new directory using the existing filename.  Then use Breezebrowser to rename the files by extracting the "file number suffix" from the original filename and making sure there is sufficient information in the new filename to create a one-to-one mapping.  Then upload the new files to the website.
    I stil don't see how to get the original file name into the metadate of the new filename though?l
    Really I should be able to do all this in Lightroom.

  • Is it appropriate to use File.createTempFile() in webstart applications?

    Hello everyone.
    I'm currently involved in developing a web start application for my company; and I am a bit puzzled as to the way temporary storage should be managed in the client's machine. To begin with, the application is a web start "trusted" application, since we're signing it.
    Specifically, the application needs to perform XSLT transformations with user-generated data. This obviously needs some place to read a source XML document and a source XML stylesheet.
    Loading the latter from my application jars as a URL isn't much of a problem. However, my confusion is regarding the location where the XML document generated by the user should be temporarily stored, since only the output of the transform is relevant.
    So the first option I got is to use the muffin storage system provided by web start. The concern I have with this is that, while it does provide a place for applications to store data, the mechanics needed to maintain muffin data do not seem (this is just a personal opinion) friendly enough for storing temporary data (an XML file in my case).
    Now, I find that a better alternative for doing this would be to use File.createTempFile() in order to request a temporary storage location to dump the XML data to transform.
    Now, bearing this in mind; is it ok for this trusted application to use the facility provided by the File class? Or is there any better way I could do this?
    Thanks for your time and help!

    jzazueta wrote:
    Well, basically the intent is that the result of the transform will be used to derive a report from another application. Now, the nature of the transform's output file is about 3 to 4 MB when generated.
    I believe that is the primary purpose of saving transformed output.Fair enough but then why do you need to create the intermediate temporary file. Can't you just process the transformed data sequentially as it is produced.
    >
    In fact, while looking further into this subject, I found some code from the JDIC project mailing list where the example seems to indicate that some level of File functionality is allowed while running under Webstart.I use files under Webstart but I do sign the jars.
    >
    [http://markmail.org/message/vhjdnwqwjdyvwliv?q=createTempFile+webstart]
    So probably the idea may not be too crazy at all :PI never said it was crazy - I just queried the need for the intermediate file. You don't give any details of what you are doing with the transformed xml so I still question the need for the intermediate file.

  • File.createTempFile seems to be broken in JDK 1.6.0_11

    Hi!
    Can anyone confirm please?
    On (German) Windows XP systems, since JDK 1.6.0_11, there seems to be a serious bug in the implementation of File.createTempFile: After having created such a temp file, using getPath() or getAbsolutePath() may show a broken path, with abbreviated path components.
    Here is an example result path (broken):
    "C:\DOKUME~1\schneid\LOKALE~1\Temp\temp_file6617344501941011051.tmp"
    As you can see, the directory "DOKUMENTE_UND_EINSTELLUNGEN" (German version of Windows XP) is abbreviated to "DOKUME~1".
    I have attached an executable Java class that shows the problem.
    If someone confirms, then I will post an issue.
    Best,
    Michael
    ======= BEGIN CLASS "CreateTempFileBug" ================
    import java.io.File;
    * Bug: Broken path for File.createTempFile
    * Description:
    * File.createTempFile() creates a file object with a broken getPath() string.
    * The path string contains "~", i.e. the path elements are abbreviated.
    * Same problem for getAbsolutePath(). Valid paths only for getCanonicalPath().
    * Example-Output:
    * "C:\DOKUME~1\schneid\LOKALE~1\Temp\temp_file6617344501941011051.tmp"
    * System:
    * OS: WinXP / German
    * JRE: 1.6.0_11
    * Since:
    * I think this is new to patch level 11 of Java 6. It breaks my software,
    * but in earlier versions everything was fine.
    * @author Michael Schneider ([email protected])
    public class CreateTempFileBug {
         public static void main(String[] args) throws Exception {
              // Creating a temporary file, and printing the path.
              // RESULT: broken path (having abbreviated path elements)
              // for getPath and getAbsolutePath, but ok for getCanoncialPath
              File tempFile = File.createTempFile("temp_file", null);
              System.out.println("temp file / getPath: BROKEN: <" + tempFile.getPath() + ">");
              System.out.println("temp file / getAbsolutePath: BROKEN: <" + tempFile.getAbsolutePath() + ">");
              System.out.println("temp file / getCanonicalPath: OK: <" + tempFile.getCanonicalPath() + ">");
              // For comparison, creating a normal file in the working dir
              // and printing the absolute path.
              // RESULT: valid paths (at least on my system)
              File normalFile = new File("normal_file");
              System.out.println("normal file / getPath: OK: <" + normalFile.getPath() + ">");
              System.out.println("normal file / getAbsolutePath: OK: <" + normalFile.getAbsolutePath() + ">");
              System.out.println("normal file / getCanonicalPath: OK: <" + normalFile.getCanonicalPath() + ">");
    ===== END CLASS =====================================
    Edited by: m_schnei on Feb 13, 2009 11:17 PM
    Edited by: m_schnei on Feb 13, 2009 11:20 PM

    Hi Danny!
    So you are saying that this is a valid path specification in Windows? I did not know this. And I do not remember to ever have seen this before with Java.
    Is there a reason why this "abbreviated" form is used in Java?
    Has this changed recently, or did I simply never found it before?
    Can this be behavior be changed to the complete path form? I like to call 'get[Absolute]Path()' in log messages and test cases, but want to see the complete path in such a case. I would like to avoid getCanonicalPath() in such cases, because this method declares an exception.
    Cheers,
    Michael

  • TestStand sub-sequence naming problem: "Step" column doesn't match "View" menu

    Refer to the attached screenshoot; when I rename the sub-sequences in the "Step" column to the left, these names don't show up in the "View" menu pull-down list shown on the right. What's going on here?
    All my sequences are in one .seq file.
    Attachments:
    Sequence Naming Problem.gif ‏31 KB

    They're not supposed to. When you rename a step, that's not the same thing as renaming a sub-sequence. Say you have a sub-sequence called x, you could have steps called "call sequence x_1", "call sequence x_2", "call sequence x_3", etc., all calling the same sub-sequence. It's no different than the different labels you might have every time you call a pass/fail step.

  • Error File.createTempFile permission to delete has not been granted

    Hi,
    I am new in Java. I wrote something easy like this:
    public class Utils {
    public static String createMyTempFile() {
    String result = "";
    try {
    File file = File.createTempFile("test",".txt");
    file.deleteOnExit();
    catch(Exception e){
    result = e.getMessage();
    return result;
    But appear the next error message:
    "Unable to create temporary file"
    But i run the same script with SYS user theres no problem, asume is a permission problem, but i dont know which permissions or how can i grant it.
    Thank you

    Grant Privileges
    The relevant permissions must be granted from SYS for JServer to access the file system:
    EXEC DBMS_JAVA.grant_permission('SCHEMA-NAME', 'java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
    EXEC DBMS_JAVA.grant_permission('SCHEMA-NAME', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    EXEC DBMS_JAVA.grant_permission('SCHEMA-NAME', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    GRANT JAVAUSERPRIV TO SCHEMA-NAME;
    The affects of the grant will not be noticed until the grantee reconnects. It is up to the individual to decide on the level of access that is required.
    Depending on the documentation used, you may be told to add the directories you intend to access to your UTL_FILE_DIR parameter in the Init.ora file. I have not found this to be necessary when using the Java approach.

  • Time machine: An error occurred while copying files. The problem could be temporary. If the problem persists, use Disk Utility to repair your backup disk.

    Time machine backups are failing. I've followed the instructions I found on the Time Machine troubleshooting page (http://pondini.org/TM/Troubleshooting.html) but have gotten to where I don't know what to do next.
    Sequence of events:
    The main error message is always:
    An error occurred while copying files. The problem could be temporary. If the problem persists, use Disk Utility to repair your backup disk.
    Yesterday, I opened Disk Utility and verified the disk. Got this error:
    Error: This disk needs to be repaired using the Recovery HD. Restart your computer, holding down the Command key and the R key until you see the Apple logo. When the OS X Utilities window appears, choose Disk Utility.
    I ran Disk Utility and repaired the hard drive. Then I manually started the backup before going to bed, figuring it was going to take a long time to run. When I got up this morning, the backup had failed with the same "could be temporary" error. I checked the log, which says:
    Starting manual backup
    Attempting to mount network destination URL: afp://Tery%20Griffin;[email protected]/Tery%20Griffin's%20Time%20Ca psule
    Mounted network destination at mount point: /Volumes/Tery Griffin's Time Capsule using URL: afp://Tery%20Griffin;[email protected]/Tery%20Griffin's%20Time%20Ca psule
    Disk image /Volumes/Tery Griffin's Time Capsule/Tery Griffin’s Computer (44).sparsebundle mounted at: /Volumes/Time Machine Backups
    Backing up to: /Volumes/Time Machine Backups/Backups.backupdb
    Event store UUIDs don't match for volume: Macintosh HD
    Error: (-36) Applying backup protections to /Volumes/Time Machine Backups/Backups.backupdb/Tery Griffin’s Computer (44)/2014-03-05-201742.inProgress/ABB10CF2-F041-4DE5-B6AE-3C228B59ADCC
    Error: (5) setxattr for key:com.apple.backupd.SnapshotStartDate path:/Volumes/Time Machine Backups/Backups.backupdb/Tery Griffin’s Computer (44)/2014-03-05-201742.inProgress/ABB10CF2-F041-4DE5-B6AE-3C228B59ADCC size:17
    Error: (5) setxattr for key:com.apple.backupd.SnapshotState path:/Volumes/Time Machine Backups/Backups.backupdb/Tery Griffin’s Computer (44)/2014-03-05-201742.inProgress/ABB10CF2-F041-4DE5-B6AE-3C228B59ADCC size:2
    Deep event scan at path:/ reason:must scan subdirs|new event db|
    Finished scan
    Found 145601 files (11.88 GB) needing backup
    16.1 GB required (including padding), 620.77 GB available
    Copied Zero KB of 11.88 GB, 0 of 145601 items
    Copied 0 files (Zero KB) from volume Macintosh HD.
    Copy stage failed with error:11
    Backup failed with error: 11
    Ejected Time Machine disk image: /Volumes/Tery Griffin's Time Capsule/Tery Griffin’s Computer (44).sparsebundle
    Ejected Time Machine network volume.
    Starting automatic backup
    Attempting to mount network destination URL: afp://Tery%20Griffin;[email protected]/Tery%20Griffin's%20Time%20Ca psule
    Mounted network destination at mount point: /Volumes/Tery Griffin's Time Capsule using URL: afp://Tery%20Griffin;[email protected]/Tery%20Griffin's%20Time%20Ca psule
    Disk image /Volumes/Tery Griffin's Time Capsule/Tery Griffin’s Computer (44).sparsebundle mounted at: /Volumes/Time Machine Backups
    Backing up to: /Volumes/Time Machine Backups/Backups.backupdb
    Event store UUIDs don't match for volume: Macintosh HD
    Error: (-36) Applying backup protections to /Volumes/Time Machine Backups/Backups.backupdb/Tery Griffin’s Computer (44)/2014-03-05-201742.inProgress/9F8E7957-9C50-49C3-8314-880E5203E3D9
    Error: (5) setxattr for key:com.apple.backupd.SnapshotStartDate path:/Volumes/Time Machine Backups/
    Does anyone know what the problem is here and what I should do?
    Thanks,
    Tery

    You have repaired your boot drive (which is good) but have you repaired your time machine drive?  I don't own a Time Capsule so I don't know if disk utility can operate on it.  If it can, you should repair it as well.  You may need to erase it and start a new backup.  That happens to time machine volumes from time to time and is why people who are serious about their data never rely on a single source of backup.

  • Can anyone help me?Time Machine couldn't complete the backup to...  An error occurred while copying files. The problem may be temporary. If the problem persists, use Disk Utility to repair your backup disk.  What is the problem?  I've made no changes.

    I recently starting receiving the error message "Time Machine couldn't complete the backup to... An erro occurred while copying files.  The problem may be temporary.  If the problem persists, use Disk Utility to repair your backup disk.  I have had no problems backing up my MacBook Pro 2011 to my Western Digital My Book Live through a Linksys EA4500 router until recently.  I've made no major changes.  I've ran a diagnosis on my back up drive with no problems.  The Time Machine back up starts, but about after about 5 to 10 minutes I get the error message.  I can see the shared drive in Finder.  The light on the drive blinks while it starts the back up.  I can see the shared folders on the networked drive.  The backup process starts but for some reason it just stops.  Can anyone help?

    You can't repair a network volume in Disk Utility.
    Backing up to a third-party NAS with Time Machine is risky, and unacceptably risky if it's your only backup. I know this isn't the answer you want, and I also know that the manufacturer says the device will work with Time Machine, and that it usually seems to work. Except when you try to restore, and find that you can't.
    If you want network backup with Time Machine, use as the destination either an Apple Time Capsule or an external hard drive connected to another Mac or to an 802.11ac AirPort base station. Only the 802.11ac base stations support Time Machine, not any older model.
    If you're determined to keep using the NAS for backup, your only recourse for any problems that result is to the manufacturer (which will blame Apple.)

  • I just got a new Mac Mini, and now when I try to import photos into Lightroom, iPhoto try to load them first, then Lightroom can't find the files.  Big problem.  What to do?

    I just got a new Mac Mini, and now when I try to import photos into Lightroom, iPhoto ties to load them first, then Lightroom can't find the files.  Big problem.  What to do?

    Simple:
    File -> Export to get your photos out of the iPhoto Library. In the Export dialogue you can set the kind to Original and you'll get back exactly what you put in.
    Apps like iPhoto2Disk or PhotoShare will help you export to a Folder tree matching your Events.
    Once exported, you can then trash the iPhoto Library - just drag it from the Pictures Folder to the trash and empty it.
    After that, if you're entirely neurotic about it, just put the iPhoto app in the trash and empty it.
    Regards
    TD

  • How to debug file content conversion problems?

    Hi,
    I'm trying to debug a file content conversion problem.  I'm mapping a few nodes in an IDOC to a file of fixed length fields.  I'm using the "<Node A>.fieldFixedLengths", "<Node B>.fieldFixedLengths", "<Node C>.fieldFixedLengths", etc. parameters to specify the fixed length records.
    However, a certain node (for e.g. Node B) is causing a problem and if it is present in the IDOC, the output file does not get created.  Upon checking the XI monitor, I notice that the file gets mapped correctly and thus the problem lies when the file adapter does the file content conversion.  How do I debug this because there is no descriptive error in the XI log?  If this node is not present, the file gets generated fine.
    Thanks,
    Basant Gupta

    Hi,
    If your SXMB_MONI shows, success status, then go to RWB->Message Monitoring->Message display tool and then check Audit log for the analysis,
    So it wil help you debug the situation.
    If there is no error, then check RWB->Component Monitoring->Adapter Monitoring for you file communciation channel..
    /people/michal.krawczyk2/blog/2005/01/02/simple-adapter-and-message-monitoring
    Regards,
    Moorthy

  • File Proxy Service Problem on errors

    In continuation of this thread...
    File Proxy Service Problem on errors
    We are now facing two problems.
    1.The proxy service is executed twice
    2.File is getting moved to error directory with prefixed file names which we are not able to retrieve and use in the notification email.
    Not sure how to fix :(

    1.The proxy service is executed twice Check if this is due to transaction timeout issue as discussed here. Re: OSB File polling working twice with the same file
    2.File is getting moved to error directory with prefixed file names which we are not able to retrieve and use in the notification email.I am not sure wehther you have any option here. You can check with support. Alternatively can raise notification mail with the timestamp and some file/business identifier from the file. The support person can then open the file from error directory to verify the file/business id in the file or educate the support user that the files will have a prefix

  • Error -43  when try playback on win7 64bits over the network QT that recide MacPro  osx 10.5 however i can play with VLC player, This happend when the QT is inside a Folder with name longer 8 chars other files has no problem with long names just the QT

    error -43  when try playback on win7 64bits over the network QT that recide MacPro  osx 10.5 however i can play with VLC player, This happend when the QT is inside a Folder with name longer 8 chars other files has no problem with long names just the QT  nfs sharing

    Never mind, I already found the solution myself.
    What I did wrong was:
    - not copying the master image to the nbi folder
    - selecting the netinstall-restore.dmg image as source to copy to my HD.
    The thing is, when you create a netinstall image for 10.5, the image itself is already included in the netinstall image so you don't have to do anything else.
    With the 10.4 image however, you also have to copy the master image to the NetBootSP0 directory.
    In the *.nbi folder contains an netinstall-restore.dmg file. But that is only to boot you to netrestore, it's not the image itself.
    Other alternative is to copy the images to another folder that you share with AFP and adjust the configuration of netrestore like described in this manual:
    http://www.shellharbourd.det.nsw.edu.au/pdf/misc/osxrestoringnet.pdf
    This manual was also how I figured out that I forgot to copy the image to the NetBootSP0 folder.

  • Time Machine Error: "An error occurred while copying files. The problem may be temporary. If the problem persists, use Disk Utility to repair your backup disk."

    I have a MacBook Pro 2.8 GHz Intel Core 2 Duo with 4GB, 500GB HDD, running 10.8.2 My computer as been running slow and fearing my HDD might die. I bought a brand new 1TB G-Drive from Apple yesterday and started my back up. It gets to just over 22GB backed up then I get this error message:
    "An error occurred while copying files. The problem may be temporary. If the problem persists, use Disk Utility to repair your backup disk."
    Anyone out there who might be able to help me fix this?

    I have a MacBook Pro 2.8 GHz Intel Core 2 Duo with 4GB, 500GB HDD, running 10.8.2 My computer as been running slow and fearing my HDD might die. I bought a brand new 1TB G-Drive from Apple yesterday and started my back up. It gets to just over 22GB backed up then I get this error message:
    "An error occurred while copying files. The problem may be temporary. If the problem persists, use Disk Utility to repair your backup disk."
    Anyone out there who might be able to help me fix this?

  • Un-Named Problem

    This is my Server Program
    import javax.swing.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    class Validation
         Object object;
         public static Vector v1=new Vector(1,1);
         Vector vctUsername = new Vector(1,1);
         public Validation(String ipAddress1, String message1)
              message1.trim();
              if(checkIP(ipAddress1))
              else
                   v1.add(ipAddress1);
                   System.out.println("IP Added");
              String check = new String(String.valueOf(message1.charAt(0)));
              if(message1.length()==0)
              else if(message1.equals("A"))
                   System.out.println("Join in Message .. not to be sent");
              else if(check.equals("�"))
                   StringTokenizer str = new StringTokenizer(message1,"�");
                   String username13 = (str.nextToken());
                   String dust13 = (str.nextToken());
                   System.out.println(dust13);
                   if(dust13.equals(new String(" has joined the conversation")));
                   System.out.println(username13);
                   vctUsername.add(username13);
                   NewServer.listNames.setListData(vctUsername);
              else
                   for(int i=0; i<v1.size(); i++)
                        try
                             object = v1.elementAt(i);
                             Socket socket = new Socket(object.toString(),4001);
                             System.out.println("Connection formed with Client "+object.toString());
                             ObjectOutputStream toClient = null;
                             toClient = new ObjectOutputStream(socket.getOutputStream());
                             toClient.writeObject(message1);
                             toClient.flush();
                             System.out.println("Message "+message1+"to IP -- "+object.toString());
                             toClient.close();
                             socket.close();
                        catch(ConnectException e1)
                             for(int ii=0; ii<v1.size(); ii++)
                                  Object object1 = v1.elementAt(ii);
                                  if(object1.toString().equals(object.toString()))
                                       v1.removeElementAt(ii);
                                       vctUsername.removeElementAt(ii);
                                       NewServer.listNames.setListData(vctUsername);
                                  else
                        catch(Exception e)
                             System.out.println("Error : "+e);
         public boolean checkIP(String ipAddress2)
              for(int i=0; i < v1.size(); i++)
                   Object object = v1.elementAt(i);
                   if(object.toString().equals(ipAddress2))
                        return true;
              return false;
    public class NewServer
         public static JList listNames;
         private     ServerSocket chatSocket;
         public NewServer()
              Object object;
              JFrame frameMain = new JFrame("Server");
              JPanel panelMain = new JPanel();
              JTextArea textAreaDisplay = new JTextArea(25,50);
              JScrollPane scrollPaneBoard = new JScrollPane(textAreaDisplay);
              listNames = new JList();
              frameMain.getContentPane().add(panelMain);
              frameMain.setVisible(true);
              frameMain.setSize(200,200);
              panelMain.add(scrollPaneBoard);
              panelMain.add(listNames);
              textAreaDisplay.setLineWrap(true);
              try
                   chatSocket = new ServerSocket(4000);
              catch(BindException e)
                   JOptionPane.showMessageDialog(frameMain, new String("Port Address in use"));
                   System.exit(0);
              catch(Exception e)
                   System.out.println("Error 1 "+e);
              while(true)
                   try
                        System.out.println("Waiting for connections .. ");
                        Socket client = chatSocket.accept();
                        String inetAddress = String.valueOf(client.getInetAddress());
                        StringTokenizer str = new StringTokenizer(inetAddress,"/");
                        String hostName = (str.nextToken());
                        String ipAddress = (str.nextToken());
                        System.out.println("Accepted connection from : "+hostName+" : "+ipAddress);
                        new Validation(ipAddress, "A");
                        try
                             ObjectInputStream fromClient = null;
                             client.setSoTimeout(1000);
                             fromClient = new ObjectInputStream(client.getInputStream());
                             String x;
                             x = (String) fromClient.readObject();
                             textAreaDisplay.append(x);
                             textAreaDisplay.append("\n");
                             new Validation(ipAddress, x);
                        catch(Exception e)
                             System.out.println("Error 3 "+e);
                   catch(NullPointerException e)
                        JOptionPane.showMessageDialog(frameMain, new String("An unexpected error occured while starting the Server -- Error - "+e));
                        System.exit(0);
                   catch(Exception e)
                        System.out.println("Error 2 "+e);
         public static void main(String args[])
              new NewServer();
    this is my Client Program
    import java.io.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.net.*;
    import javax.swing.*;
    public class NewClient
         JFrame frameMain1;
         JPanel panelMain1;
         JTextArea textAreaDisplay;
         JScrollPane scrollPaneDisplay;
         JTextField textFieldMessage;
         Socket socket;     
         ObjectInputStream fromServer;
         ServerSocket inputServerSocket;
         String username123;
         public NewClient(String username12)
              frameMain1 = new JFrame("Client");
              panelMain1 = new JPanel();
              textAreaDisplay = new JTextArea(25,50);
              scrollPaneDisplay = new JScrollPane(textAreaDisplay);
              textAreaDisplay.setLineWrap(true);
              panelMain1.add(scrollPaneDisplay);
              System.out.println("coming 1");
              textFieldMessage = new JTextField(50);
              panelMain1.add(textFieldMessage);
              textFieldMessage.addKeyListener(new listener());
              frameMain1.getContentPane().add(panelMain1);
              frameMain1.setSize(200,200);
              frameMain1.setVisible(true);
              System.out.println("coming 3");
              try
                   socket = new Socket("192.168.16.1",4000);
                   inputServerSocket = new ServerSocket(4001);
                   ObjectOutputStream toServer = new ObjectOutputStream(socket.getOutputStream());
                   toServer.writeObject("� "+username12+" � has joined the conversation");
                   toServer.flush();
                   toServer.close();
              catch(UnknownHostException e)
                   JOptionPane.showMessageDialog(frameMain1, new String("Host Not Found "+e));
                   System.exit(0);
              catch(ConnectException e)
                   JOptionPane.showMessageDialog(frameMain1, new String("Connection Failed Because "+e));
                   System.exit(0);
              catch(BindException e)
                   JOptionPane.showMessageDialog(frameMain1, new String("Client Application already running or Port in use"));
                   System.exit(0);
              catch(Exception e)
                   JOptionPane.showMessageDialog(frameMain1, new String("An unexpected Error occured "+e));
                   System.exit(0);
              try
                   while(true)
                        Socket listener = inputServerSocket.accept();
                        ObjectInputStream fromClient = null;
                        listener.setSoTimeout(1000);
                        fromServer = new ObjectInputStream(listener.getInputStream());
                        String input = (String) fromServer.readObject();
                        textAreaDisplay.append("\n");
                        textAreaDisplay.append(input);
                        fromServer.close();
                        listener.close();
              catch(Exception e)
                   JOptionPane.showMessageDialog(frameMain1, new String("An unexpected Error occured "+e));
         class listener implements KeyListener
              public void keyTyped(KeyEvent e)
              public void keyReleased(KeyEvent e)
              public void keyPressed(KeyEvent e)
                   int code = e.getKeyCode();
                   if(code == KeyEvent.VK_ENTER)
                        String message12 = textFieldMessage.getText();
                        message12.trim();
                        if(message12.length()==0)
                        else
                             try
                                  Socket socket1;
                                  socket1 = new Socket("192.168.16.1",4000);
                                  ObjectOutputStream toServer = new ObjectOutputStream(socket1.getOutputStream());
                                  String messageTyped;
                                  messageTyped = (username123+" says::"+message12);
                                  toServer.writeObject(messageTyped);
                                  toServer.flush();
                                  textFieldMessage.setText("");
                                  toServer.close();
                                  socket1.close();
                             catch(ConnectException e1)
                                  JOptionPane.showMessageDialog(frameMain1, new String("Server Down"));
                                  System.exit(0);
                             catch(Exception e2)
                                  JOptionPane.showMessageDialog(frameMain1, new String("Error : "+e2));
                                  System.exit(0);
         public static void main(String args[])
              new NewClient("Guest_Null");
    and this is the program ...thru which i am calling ... Newclient
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    import java.sql.*;
    public class Prashant extends JFrame
         //----frameMain objects
         JFrame frameMain = new JFrame("");     
         //----panelMain objects
         JPanel panelMain = new JPanel();
         CardLayout c1 = new CardLayout();
         //----panelAdministrator
         JPanel panelAdministrator = new JPanel();
         JTable table = new JTable();
         //----panelWelcome objects
         JPanel panelWelcome = new JPanel();
         String stringFirstName2 = new String("User");
         JLabel labelFirstName1=new JLabel("");
         //----panelLogin objects
         JPanel panelLogin = new JPanel();
         JLabel labelUsername2 = new JLabel("Username");
         JTextField textFieldUsername2 = new JTextField(10);
         JLabel labelPassword1 = new JLabel("Password");
         JPasswordField passwordFieldPassword1 = new JPasswordField(10);
         JButton buttonLogin = new JButton("Login");
         JButton buttonNewUser = new JButton("New User, Sign Up");
         //----panelInsertData objects
         JPanel panelInsertData = new JPanel();
         JLabel labelUsername1 = new JLabel("Username");
         JTextField textFieldUsername1 = new JTextField(10);
         JLabel labelPassword = new JLabel("Password");
         JPasswordField passwordFieldPassword = new JPasswordField(10);
         JLabel labelReTypePassword = new JLabel("Re-Type Password");
         JPasswordField passwordFieldReTypePassword = new JPasswordField(10);
         JLabel labelFirstName = new JLabel("First Name");
         JTextField textFieldFirstName = new JTextField(10);
         JLabel labelLastName = new JLabel("Last Name");
         JTextField textFieldLastName = new JTextField(10);
         JLabel labelPhoneNumber = new JLabel("Phone Number");
         JTextField textFieldPhoneNumber = new JTextField(10);
         JLabel labelAddress = new JLabel("Address");
         JTextArea textAreaAddress = new JTextArea("",10,10);
         JScrollPane scrollPaneAddress = new JScrollPane(textAreaAddress);
         ClickListen ClickListener = new ClickListen();
         JButton buttonSubmit = new JButton("Submit");
         //----panelRetieveData objects
         JPanel panelRetieveData = new JPanel();
         JButton testButton = new JButton("Retieve Data");
         //----panelUsernameSearch
         JPanel panelUsernameSearch = new JPanel();
         JLabel labelUsername = new JLabel("Username");
         JTextField textFieldUsername = new JTextField(10);
         JButton buttonCheckForAvailability = new JButton("Check");
         public void frameMain()
              frameMain.setResizable(true);
         public void panelMainClass()
              frameMain.getContentPane().add(panelMain);
              panelMain.setLayout(c1);
         public void panelWelcome()
              panelMain.add(panelWelcome, "panelWelcome");
              panelWelcome.setLayout(null);
              panelWelcome.add(labelFirstName1);
              labelFirstName1.setBounds(10,10,200,25);
         public void panelAdministrator()
              panelMain.add(panelAdministrator,"panelAdministrator");
              panelAdministrator.add(table);
         public void panelLogin()
              frameMain.setSize(195,160);
              frameMain.setVisible(true);
              panelLogin.setLayout(null);
              panelMain.add(panelLogin, "panelLogin");
              c1.show(panelMain, "panelLogin");
              panelLogin.add(labelUsername2);
              labelUsername2.setBounds(10,10,100,25);
              panelLogin.add(textFieldUsername2);
              textFieldUsername2.setBounds(75,10,100,25);
              panelLogin.add(labelPassword1);
              labelPassword1.setBounds(10,40,100,25);
              panelLogin.add(passwordFieldPassword1);
              passwordFieldPassword1.setBounds(75,40,100,25);
              panelLogin.add(buttonLogin);
              buttonLogin.setBounds(10,70,165,25);
              buttonLogin.addActionListener(ClickListener);
              panelLogin.add(buttonNewUser);
              buttonNewUser.setBounds(10,100,165,25);
              buttonNewUser.addActionListener(ClickListener);
         public void panelUsernameSearch()
              panelMain.add(panelUsernameSearch,"panelUsernameSearch");
              panelUsernameSearch.setLayout(null);
              panelUsernameSearch.add(labelUsername);
              labelUsername.setBounds(10,10,60,25);
              panelUsernameSearch.add(textFieldUsername);
              textFieldUsername.setBounds(75,10,100,25);
              panelUsernameSearch.add(buttonCheckForAvailability);
              buttonCheckForAvailability.setBounds(10,40,165,25);
              buttonCheckForAvailability.addActionListener(ClickListener);
         public void panelInsertDataClass()
              panelInsertData.setLayout(null);
              panelMain.add(panelInsertData, "panelInsertData");
              labelUsername1.setBounds(10,10,100,25);
              panelInsertData.add(labelUsername1);
              textFieldUsername1.setBounds(115,10,100,25);
              textFieldUsername1.setEnabled(false);
              textFieldUsername1.setText("Prashant");
              panelInsertData.add(textFieldUsername1);
              labelPassword.setBounds(10,40,100,25);
              panelInsertData.add(labelPassword);
              passwordFieldPassword.setBounds(115,40,100,25);
              panelInsertData.add(passwordFieldPassword);
              labelReTypePassword.setBounds(10,70,100,25);
              panelInsertData.add(labelReTypePassword);
              passwordFieldReTypePassword.setBounds(115,70,100,25);
              panelInsertData.add(passwordFieldReTypePassword);
              labelFirstName.setBounds(10,100,100,25);
              panelInsertData.add(labelFirstName);
              textFieldFirstName.setBounds(115,100,100,25);
              panelInsertData.add(textFieldFirstName);
              labelLastName.setBounds(10,130,100,25);     
              panelInsertData.add(labelLastName);
              textFieldLastName.setBounds(115,130,100,25);
              panelInsertData.add(textFieldLastName);
              labelPhoneNumber.setBounds(10,160,100,25);
              panelInsertData.add(labelPhoneNumber);
              textFieldPhoneNumber.setBounds(115,160,100,25);
              panelInsertData.add(textFieldPhoneNumber);
              labelAddress.setBounds(10,190,100,25);
              panelInsertData.add(labelAddress);
              textAreaAddress.setLineWrap(true);
              scrollPaneAddress.setBounds(115,190,100,75);
              panelInsertData.add(scrollPaneAddress);
              panelInsertData.add(buttonSubmit);          
              buttonSubmit.addActionListener(ClickListener);
              buttonSubmit.setBounds(10,270,205,25);
         public void panelRetieveDataClass()
              panelMain.add(panelRetieveData, "panelRetieveData");               
              panelRetieveData.add(testButton);
         class ClickListen implements ActionListener
              public void actionPerformed(ActionEvent evt)
                   Object obj = evt.getSource();
                   if(obj==buttonLogin)
                        String stringUsername2 = new String(textFieldUsername2.getText());
                        if(stringUsername2.length()==0)
                             JOptionPane.showMessageDialog(frameMain, new String("Username field cannot be left empty"));
                        else
                             String stringPassword1 = new String(passwordFieldPassword1.getPassword());
                             if(stringPassword1.length()==0)
                                  JOptionPane.showMessageDialog(frameMain,new String("Password field cannot be left empty"));
                             else
                                  if(stringUsername2.equals("Administrator"))
                                       if(stringPassword1.equals("Prashant"))
                                            JOptionPane.showMessageDialog(frameMain,new String("Welcome Mr.Prashant"));
                                            c1.show(panelMain, "panelAdministrator");
                                       else
                                            JOptionPane.showMessageDialog(frameMain,new String("Invalid Password"));
                                  else
                                       try
                                            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                                            Connection con2;
                                            con2 = DriverManager.getConnection("jdbc:odbc:prashant","user1","");
                                            PreparedStatement stat2 = con2.prepareStatement("select * from prashant_registration where username = ? AND cpassword = ?");
                                            stat2.setString(1, stringUsername2);
                                            stat2.setString(2, stringPassword1);
                                            ResultSet result;
                                            result = stat2.executeQuery();
                                            if(result.next())
                                                 JOptionPane.showMessageDialog(frameMain,new String("Login successful"));
                                                 stringFirstName2 = result.getString(3);
                                                 labelFirstName1.setText("Welcome "+stringFirstName2);
                                                 new NewClient(stringUsername2);
                                                 c1.show(panelMain, "panelWelcome");
                                            else
                                                 JOptionPane.showMessageDialog(frameMain,new String("Login Failed"));
                                                 textFieldUsername2.setText("");
                                                 passwordFieldPassword1.setText("");
                                       catch(Exception e)
                                            System.out.println("error" +e);
                   if(obj==buttonNewUser)
                        c1.show(panelMain, "panelUsernameSearch");
                        frameMain.setSize(190,100);
                        frameMain.setVisible(true);
                   if(obj==buttonCheckForAvailability)
                        String stringUsername = textFieldUsername.getText();
                        if(stringUsername.length()==0)
                             JOptionPane.showMessageDialog(frameMain,new String("Username cannot be left blank"));
                        else
                             try
                                  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                                  Connection con1;
                                  con1 = DriverManager.getConnection("jdbc:odbc:prashant","user1","");
                                  PreparedStatement stat1 = con1.prepareStatement("select * from prashant_registration where username = ?");
                                  stat1.setString(1, textFieldUsername.getText());
                                  ResultSet result;
                                  result = stat1.executeQuery();
                                  if(result.next())
                                       JOptionPane.showMessageDialog(frameMain,new String("Username is not Avaiable, Click Ok, to choose someother username"));
                                       textFieldUsername.setText("");
                                  else
                                       JOptionPane.showMessageDialog(frameMain, new String("Username is available, Click Ok, to move to the next step"));
                                       textFieldUsername1.setText(textFieldUsername.getText());
                                       frameMain.setSize(230,330);
                                       frameMain.setVisible(true);
                                       c1.show(panelMain, "panelInsertData");
                             catch(SQLException sqlex)
                                  System.out.println ("SQLState: " + sqlex.getSQLState () + "");
                                  System.out.println ("Message: " + sqlex.getMessage() + "");
                                  System.out.println ("Vendor ErrorCode: " + sqlex.getErrorCode() + "");
                             catch(Exception ex1)
                                  System.out.println("Error ex1" +ex1);
                   if(obj==buttonSubmit)
                        String stringPassword = new String(passwordFieldPassword.getPassword());
                        if(stringPassword.length()==0)
                             JOptionPane.showMessageDialog(frameMain, new String("Password field cannot be left empty"));
                        else
                             String stringReTypePassword = new String(passwordFieldReTypePassword.getPassword());
                             if(stringReTypePassword.length()==0)
                                  JOptionPane.showMessageDialog(frameMain, new String("Please ReType the password"));
                             else
                                  if(stringPassword.equals(stringReTypePassword))
                                       if((new String(textFieldFirstName.getText())).length()==0)
                                            JOptionPane.showMessageDialog(frameMain,new String("FirstName cannot be left blank"));
                                       else
                                            if((new String(textFieldLastName.getText())).length()==0)
                                                 JOptionPane.showMessageDialog(frameMain,new String("LastName cannot be left blank"));
                                            else
                                                 if((new String(textFieldPhoneNumber.getText())).length()==0)
                                                      JOptionPane.showMessageDialog(frameMain,new String("Phone Number cannot be left blank"));
                                                 else
                                                      if((new String(textAreaAddress.getText())).length()==0)
                                                           JOptionPane.showMessageDialog(frameMain,new String("Address Cannot Be Left Blank"));
                                                      else
                                                           try
                                                                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                                                                Connection con;
                                                                con = DriverManager.getConnection("jdbc:odbc:prashant","user1","");
                                                                PreparedStatement stat2 = con.prepareStatement("insert prashant_registration values(?,?,?,?,?,?, getDate(), getDate())");
                                                                stat2.setString(1,textFieldUsername1.getText());
                                                                stat2.setString(2,stringPassword);
                                                                stat2.setString(3,textFieldFirstName.getText());
                                                                stat2.setString(4,textFieldLastName.getText());
                                                                stat2.setString(5,textFieldPhoneNumber.getText());
                                                                stat2.setString(6,textAreaAddress.getText());
                                                                stat2.executeUpdate();
                                                                JOptionPane.showMessageDialog(frameMain,new String("Your Details have been registered"));
                                                                c1.show(panelMain, "panelRetieveData");
                                                           catch(SQLException ex)
                                                                System.out.println ("SQLState: " + ex.getSQLState () + "");
                                                                System.out.println ("Message: " + ex.getMessage() + "");
                                                                System.out.println ("Vendor ErrorCode: " + ex.getErrorCode() + "");
                                                           catch(Exception e)
                                                                JOptionPane.showMessageDialog(frameMain,new String("Error encountered while entering data in the database: "+e));
                                  else
                                       JOptionPane.showMessageDialog(frameMain,new String("Passwords doesnt match"));
         public static void main(String args[])
              Prashant prashant = new Prashant();
              prashant.frameMain();
              prashant.panelMainClass();
              prashant.panelLogin();
              prashant.panelWelcome();
              prashant.panelAdministrator();
              prashant.panelUsernameSearch();
              prashant.panelInsertDataClass();
              prashant.panelRetieveDataClass();
    I dont know what the problem is .... the Client program's frame is EMPTY
    my faculty and my fellow programmers said ...the program is getting hanged or something is getting overlapped
    please try and let me know what could be the possible problem could be .... people in here and myself ..couldnt solve it ... because i am not getting any error message or exception ... so it is a
    **Un-Named Problem**
    I will be really thankful to you ...if u could help me out

    When you post code, please use [code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read.

Maybe you are looking for

  • How do I add a second iTunes account to my computer?

    my wife and I share the same itunes account and I'd like to have my own account. Is it possible to create a new account on our shared macbook? Thanks

  • Mac Pro missing "Create Windows 7 Install Disk"

    Okay well when i try to use bootcamp as i already bought a copy of windows 7. The Create Windows 7 Install Disk option is not there for me. In every tutorial to setup bootcamp has had that option. Is my bootcamp messed up or did i do something wron?

  • Reducing page size of a pdf

    I have created a pdf from a multiple page A4 Word doc supplied to me. Is there a simple way to scale the page size from A4 to a smaller size and saving as a new pdf?

  • Is icould down?

    is iclould down? i can't get my itunes match to work

  • Not able to install work shop(OEPE) with WLP 10.3.6

    Hi,   I have installed weblogic portal and expected to install workshop portal extension to develop some portal applications . But after successful installation of WLP 10.3.6 i didn't see any eclipse installation in Middleware home directory. Please