JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Buffered reader just has a FIFO stack of characters supplied from the underlying input stream. Each time you call read() it pops the first char and returns it to you.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You can close() a Scanner, but if you are using System.in then the close() has no effect (System.in cannot be closed), so people don't bother.
flush() writes any buffered output to the underlying device and allows you to continue writing to it. close() writes any buffered output to the udnerlying device then closes it so you cannot write to it any more.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The inner loop code is wrong. With i == 1 it will exit on the very first execution because ! j>i

Why not just use the simple form for the inner loop ...

for (int j = i+1; j < numbers.length; j++) {
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

There's nothing to gain by messing about with a 1D array. You can start with an array of doublets (arrays with 2 members), and add solutions to that as you find them. If you overflow the size you will need to copy to as larger array, and at the end you will need to copy to a smaller array of exactly the right size.
ArrayList anybody???

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

javac.exe needs a file name, but java.exe takes a class name as its parameter, so you don't add the ".class". Ie the correct command is just
java apples
(confusing? yes, but that's how it is)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Personally I have never seen a definition of "syllable" that was logically sound - the original is based on how people happen to speak the word. Do you have a definitive algorithm/specification for "syllable" in the context of this exercise?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Check your switch, and remember that execution wuill drop through to the next clause unless you execute a break or a return...

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The code does angle calcs using 360 in one place and 2pi in another, so maybe you are mixing or confusing degrees and radians?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

They are all three the same. Their names come from different ways of looking at and thinking about lists, but in the end they all do the same thing (remove and return the first item in the list).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK. If ypur problem is solved, no need to post again. Just mark this thread "solved"

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

There are a few places inside your loops where you use i instead of x[i] or j instead of x[j]
In other words, you should be comparing and swapping the elements in the array, not the indexes.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

can you give me the correct code?

No.

This is not a "we do your homework" service, and if you submit some of our fixed code as your homework then you will deserve an "F" for cheating.

Taywin told you where the problem is, and how to start fixing it. Read and understand what he said. Correct your code accordingly. If it still doesn't work then put a load of print statements into your code, printing the values of the key variables at each stage so you can see where it's going wrong. If you're still stuck after that post your latest code and a description of what you have tried, and someone will give you some more advice.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I'd look on the web first, if nothing then do something simple with an animated GIF (unless you already have expertise in video editing).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

How about three actual pictures for the R/P/S ?
And an animation that shows the result (eg scissors cutting paper) complete with appropriate sounds?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What you have done with the variables prices (regPrice, overnightPrice) isperfectly valid, but could be a little better.
The problem is that to find out what value is used you need to look in two widely-separated places, so it's not easy for someone else to folow that code.
It's much clearer if you don't initialise them when you declare them, then set them explicitly like

if (overnightCheck == 0)
   overnightPrice = 0.00;
else
   overnightPrice = 5.00;

Incidentally, you could also use the ? operator, as in

overnightPrice = (overnightCheck == 0) ? 0 : 5;

More importantly, think what happens if the next step in this learning is
"After processing one order, ask the user if there is another to process, and continue processing orders until the user says no." With the code as you have written it, the prices will default to their values from the previous order.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

titus.k.s
Stop posting the same question twice. Next time you will get an infraction, possibly leading to a complete ban.
Read the DaniWeb rules carefully before you post again
https://www.daniweb.com/community/rules

And yes, as people have already pointed out, there's no point trying to work with GUIs and databases when you seem to have skipped over the basics.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yup, that's what you get when you print an array - it's the toString() method that arrays inherit from Object - the bracket says its an array, the I says its an array of ints, the rest is the array's hash (normally its address in memory).
To print the contents of an array you use a loop to print all the elements one at a a time. (There's also a method in the Arrays class that does that for you, but it's best if you figure it out yourself for now)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yup, that's what you get when you print an array - it's the toString() method that arrays inherit from Object - the bracket says its an array, the I says its an array of ints, the rest is the array's hash (normally its address in memory).
To print the contents of an array you use a loop to print all the elements one at a a time. (There's also a method in the Arrays class that does that for you, but it's best if you figure it out yourself for now)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The code on lines 21-36 sorts the data (or it will, when you've fixed the bug), so it has to be after that. The main method ends on line 38, so it has to be before that.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If you want to display the output (the contents of the array at the end), and you know loops and print, then what exactly is your question?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's a very good point. A standard Fisher-Yates / Knuth Shuffle on a 52 element array runs in microseconds.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, that's exactly the scenario I guessed in my first post. You cannot do it like that becuase of the way the EDT works.
SwingWorker is definitely what you should look at. The API doc starts with a couple of examples - the first one should give you what you need. In your actionPerformed set the message and call execute() for your SwingWorker. In the SwingWorker's done() method just turn the message off again.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Are you trying to do this?

actionPerformed ...
   show "busy" message
   do some stuff
   remove "busy" message

if so...

Everything to do with Swing (eg painting the screen, running actionPerformed methods) happens on a single thread - the "Event Dispatch Thread", or "EDT", or "Swing thread".
That means that once your actionPerformed method starts NOTHING else will happen in Swing, including no screen updates, until your method finishes. You can update stuff and loop and sleep as much as you like, but none of that will affect what's on the screen until your method has terminated.

The one interesting exception is if you use a JOptionPane for the busy message...

Having said all that, if the "stuff" takes long enough to notice, then it should not be on the swing thread anyway. SwingWorker is a good option.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, sorry to hear about the 1.6 requirement - I gues your client/boss knows that it's out of support and has security problems that will never be fixed?
I ran my code initially with your unchanged method, and it works 100%. The subsequent changes to the method were just because I had a spare moment and was a bit bored! I just ran it with your data file, no problem.

The important point is to call getStringFromInputStream before you call pr.waitFor

ps:
Because StringBuilder is optimised for appending, it's considered better practice to code

sb.append(line);
sb.append("\n");

rather than do string concatenation of line and \n, which requires allocation of a new String object. Having said that, I know (have seen) cases where the compiler replaces concatenated strings in a StringBuilder append by multiple calls with one string each in the generated code.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

... and a small ps - a tidied-up version of your getStringFromInputStream

    private static String getStringFromInputStream(InputStream is) {
      StringBuilder sb = new StringBuilder();
      try (BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"))) {
         // try-with-resources guarantees BufferedReader will be closed properly
         String line;
         // always declare variables in the smallest possible scope
         while ((line = br.readLine()) != null) {
            // saves repeating the read
            sb.append(line);
            sb.append("\n");
            // why do a string concatenation when you've got a StringBuffer?
         }
      } catch (IOException e) {
         e.printStackTrace();
      }
      return sb.toString().trim();
   }
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Just for reference...
I ran this code (with try/catch, imports etc), using your getStringFromInputStream method unchnaged, against a 210k text file with perfect results...

         Runtime r = Runtime.getRuntime();
         Process pr = r.exec("cmd /c type c:\\testdata\\long.txt");
         System.out.println(getStringFromInputStream(pr.getInputStream()));
         System.out.println("result " + pr.waitFor());  

... so the question is "what are you doing that's different?"

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, it certainly looks like a OS limit on the sysout buffer. Can you post your latest code because what you are trying to do is a perfectly normal thing that people do (successfully!) all the itme.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Java Stream buffer size may affect the efficiency of your execution, but it won't change whether it works or not.
Maybe the problem is that you waitFor the process to terminate before you start to read your input stream. The Process API doc says

Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, or even deadlock.

... in which case you need to swap the code around so that you read all the input from your process, before you waitFor to get the return code, like this example

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That code should be able to read the process output up to the limit of a single String. Maybe it's the logger that's the problem? Try just printing the string to System.out before returning it (at line 18)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What code are you using to process the output stream from your process?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Excellent!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You seem to have got this all twisted up, and I don't know why. I'd just make it a constructor:

public MyLayerTest(){
  ImageIcon backGround = createImageIcon("/Images/Blackjack Table.jpg");
  setPreferredSize(new Dimension(800, 600));
  //Create the JLabel for the background image and add the image.
  back = new JLabel(backGround);
  back.setBounds(0, 0, 800, 600);
  add(back, new Integer(0));
}

then in createAndShowGUI()

JComponent lp = new MyLayerTest();
frame.add(lp);

(but first I'd rename "MyLayerTest" to something that helps the code make sense like "BlackjackTable", as in

JComponent blackjackTable = new BlackjackTable();
frame.add(blackjackTable);
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I thought you maust have fixed that by now!
Is the un-executed method the myPane() method? That's not executed because you have written no code to call it. The content of that method looks like it should be the no-args constructor, in which it would be called when you new the class instance.

ps I wouldn't advise setContentPane for this purpose. Just add your layered pane to the JFrame. Then you can add other panels with buttons or toolbars etc later.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, add the listeners to the controls when you add the controls, in your layered pane class constructor.
But...
don't try to do too much in those listeners. Don't put the game logic here. Implement the logic in some other class, and in the listeners just get the event then call the appropriate method(s) in the game logic class. Ie keep a clean separation between logic and GUI.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Create a subclass of JLayeredPane. In the constructor for your class, add all the controls you want.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It sounds like your layered pane should be a class in its own right - ie extend JLayeredPane and add all the controls to it in its constructor. Then the creator class can invoke a new instance of that and add it to the JFrame.
Don't be aftraid of having too many classes!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

UCanAccess (sourceforge) may be an answer

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The parameter for split is a REGEX. In a REGEX the + character is a special character. To use it as a literal + you need to "escape" it with a single \ . To enter a single \ in a Java String you need to code a double \ (yes, messy isn't it). In summary: to split on + characaters you need to code split("\\+")
Check out the doc for java.util.regex.Pattern or any REGEX tutorial.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK. If it's a learning exercise rather than a live system, then of course you can try stuff out rather than automatically implementing "best practice". AES would be the obvious choice.
If the data is all encrypted then its hard to see what database functionality could be usefully applied, other than just store & retrive... in which case you may as well just XMLEncode and encrypt the resulting text file(s).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

This is the Java forum. That's not Java.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

See the tutorial I linked you to.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I was just referring to passwords. The other data will be OK with AES. You should never store a password, no matter how it's encrypted.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

AES is a good algorithm, especially with a long key.
You wouldn't normally store a password, no matter how it's encrypted. You store a secure one-way hash of the password (salted) which cannot be decoded. To check the user's password you process it with the same salt and hash mechanism, and check if that matches the stored value. Here's a decent tutorial:
http://www.codeproject.com/Articles/704865/Salted-Password-Hashing-Doing-it-Right

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You may have an old ClassExample.class file around somewhere from a previous compile. If so, search for and delete any files with that name.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Before you start installing some random datatbase engine, remember that Oracle's JavaDB is already on your system. It's installed as a part of the standard JDK. It works very well indeed with Java (obviously!) and NetBeans knows all about it. You can start with it as a singe-user simple embedded database engine, and move it to a multi-user server configuration later if you need. There are loads of beginner tutorials on the web, including ones specifically for NetBeans.
Unless you already have some other database engine, I can't imagine why you would not use JavaDB

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's the problem. Java doesn't have anything defined in the language spec. as "global", so you can use the word to mean anything you like. Similarly, your reader can read it to mean anything they like. Personally, if I were to use it, I wouldn't use it for anything less than a public static member or a public class.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

(This is a copy of my replies to the earlier thead - repeated here for simplicity)

That's a common problem with Swing (or any other powerful GUI toolset), and there isn't any good solution. An IDE with code folding helps when you are editing the code.
You can certainly put it all in a method in the same class, but if you use a different class then you have to worry about accessing all the variables for the different components in the GUI. If that's not too serious a problem then you can create a subclass of JPanel (or layered pane etc) that implements all the content, and in your main form just add a new one of those.

When I'm doing this for real I usually create a JPanel subclass containing all the contents, then provide a public interface in terms of the logic rather than the presentation, thus keeping all the actual JComponents private. Eg: Its a roulette application - I may have stuff like

class RouletteTable extends JPanel {
    public RouletteTable() {...
    public void showBet(int amount, Place p) {
       // enum Place is a number, colour. odd/even etc
       // may display piles of chips in the right place tec
       ...
    public int spinWheel() {
       // animated, retunrns final result

Note that this does very complicated and beautiful graphics, but it knows nothing about the processes of a game of roulette... it just displays what it's told to display.

Now I can program the logic …

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Legal Java yes, but terrible advice for someone learning Java. Making everything static is missing the whole point of an object oriented language.

Much better to remove every static keyword except the one on main, and start main by creating an instance of the class with which to call the methods.

Those variables that you think look like "globals" should actually be instance variables.

And if you want to talk about making the display nicer...
indent correctly
keep comments with the code they refer to
remove obsolete comments
insert blank lines beween major code units rather than inside them
use a consistent style for brackets
indent correctly (it's worth saying this twice)
and
always indent correctly

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Simply:
You did this:

public static void main(String[] args) {
     ...
     void changePower(int newValue) {
          Power = newValue;
     }
     etc
}

You cannot create a method inside another method. You must finish each method before you start another, like this:

public static void main(String[] args) {
     ...
}

void changePower(int newValue) {
     Power = newValue;
}
etc
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sorry, I've literally never used the console in a real application, so I can't help.

One small suggestion: you have the same format string twice in the code (lines 17 and 34). That's the kind of thung that drives you mad when you (or someone else) are trying to change that code later. Much better to declare it once
static final String TABLE_FORMAT = "|%-5s|%-20s|%-20s|\r\n";
then use that for both the headings and the data, which will therefore always match.