Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: The case of the disappearing double quotes

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default The case of the disappearing double quotes

    I have encountered a weird phenomenon. I have compiled a front-end program which lets the user select a retrogame emulator (from a list of 13), view its instructions, select from a displayed list of relevant games, and then run the selected game (using the Runtime Process). This is done by saving and running a batfile containing the appropriate command line. About half of these emulators require the game pathway to be placed between double quotes, so my commandline often takes the form-<path> + emulator.exe + space + "\"" +<path> + selected game + "\""
    My problem is that the final "\"" refuses to appear in the batfile. I have tried using \0022, (char)34, String.valueOf, Character.toString, and even a 'public static string PutIntoQuotes(string value)' function but I always end up with unclosed quotes which prevents these emulators from loading the game. (I have also used trim() on the selectedgame to make sure there are no trailing spaces.) If I load the batfile and insert the missing quotes it works OK. All very frustrating when the application runs perfectly otherwise. I have the identical program running without hitch in Lazarus Free Pascal. At the moment this a Windows 7 problem. I am now about to run the application in Linux Mint. Has anyone else encountered this weird missing character?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,324
    Thanks
    56
    Thanked 2,374 Times in 2,345 Posts

    Default Re: The case of the disappearing double quotes

    Can you print the commandline to show what it contains?
    How are you passing the commandline to the OS?

    Can you post a small, simple program that compiles, executes and shows the problem?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    May 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: The case of the disappearing double quotes

    Thanks for the suggestion that I should write a simple program to illustrate the problem. In so doing I have finally discovered the source of the problem (though not the final solution as yet). In the original program I load my lists of games from a text file into a list box for selection. I have to do this at run time since I have several emulators to cover. In my simple program I populated a list box with a few file-names manually at the start and, lo and behold the problem failed to appear. Something is happening when my filename strings are read into the list box which makes them reject the addition of a final double quotes character at the end of the command line. eg. my simple program gave me a batch file with -c:\GameBoy\VisualBoyAdvance.exe "c:\GameBoy\Files\MonsterHouse (U).zip" (which runs perfectly) whereas my full program gives a similar batch file with the same line minus the final quotes (which won't run). I shall explore other ways of setting up menus of game files. (By the way I have the same problem in Linux where I've got my program running) Thanks for your help.

  4. #4
    Junior Member
    Join Date
    May 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: The case of the disappearing double quotes

    Problem finally solved! It seems that the text files from which I populated my list box were infected by invisible control characters (other than leading and trailing spaces which I had controlled for) which contaminated the strings from which I built the command line. Java appears to be sensitive to this kind of thing since I had used these text files previously with a Pascal (Delphi) version of the program. I created the text files anew and the problem vanished.
    By the way any members who run Emulator games are welcome to a copy of my program.

Similar Threads

  1. case 3
    By ericgomez in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 31st, 2013, 07:21 PM
  2. Mysterious disappearing classes.
    By mstabosz in forum Java IDEs
    Replies: 3
    Last Post: August 1st, 2013, 01:18 PM
  3. [SOLVED] Read double from console without having to read a string and converting it to double.
    By Lord Voldemort in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: June 26th, 2011, 09:08 AM
  4. [SOLVED] Disappearing applet, where's it going?
    By bradleysm in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 29th, 2011, 09:41 PM
  5. [SOLVED] Grass disappearing :(
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 18th, 2010, 10:09 PM