masijade 1,351 Industrious Poster Team Colleague Featured Poster

On this line

close buffRead();

you have the method before the object. Is that right? No. How did you call readLine? Call close the same way.

As for "the second part" Java does not give you direct access to memory.

You should not be doing this stuff in main. You need to place it into a different method, and have that method return a String, or StringBuffer, or something to that effect. Then other parts of your program/os/whatever will simply call the method, using the filename as a parameter, and retreive the whatever as the result.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What problem are you having with it?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uuuuhhhhmmmm, then why ask this in the Java Forum.

I've already asked the mods to move this thread to the proper forum.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, we don't know what information you're including in your project either.

Ezzaral commented: Something tells me they are in for some cable problems :) +12
masijade 1,351 Industrious Poster Team Colleague Featured Poster

i know this is off topic but i needed a little help with my java progrma i posted a forum called help with BMI program, I just need a little help with were i went wrong and why its not working, so if any one can help please do so the help is much needed........

You've started your own thread, so keep your discussions there.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And, I have been called a whiz kid in the past...
I'm no genius, but I'm usually the one just below the level of genius.

And modest, too.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

This sounds like a question directly from a test or quiz (or at least homework).

All I can say is read the API documentation, as I know you are going to tell me that this question is none of those things, but I find that hard to believe (considering the question and the way it was asked).

http://java.sun.com/javaee/reference/index.jsp

masijade 1,351 Industrious Poster Team Colleague Featured Poster

How is your test going?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

http://java.sun.com/javase/6/docs/

Contains links to suns tutorials and the api docs, as well as jvm specs and the jls and a features guide. In short, Suns official Java documentation.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You stated an obvious falsehood as fact, how is that not a lie? What is there to defend? Admitting it would have evoked a better response.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

A "batch" file, as in a windows script, or a unix shell script. If the first option, then you asking in the wrong forum.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

By the way, I don't agree with the way the ParserException is written. This is not the right way to extend the Exception class

To tell you the truth, after your post I decided to give a quick look at the code, and you know what, I don't agree with the way anything is written there.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And this

I am programming using a Java Editor called "TextMate" on the mac and it often gives me errors that I don't get when I compile using TextPad on the Windows machines at school. Can someone check if this compiles on a Windows machine please?

is obviously a lie, as that code is guaranteed to fail to compile on every platform.

Ezzaral commented: Exactly what I was about to post. +11
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because, of course, you're suppossed to provide all of that. Why else would he post here, if he still had to do any of it himself?

;)

Alex Edwards commented: =P +4
masijade 1,351 Industrious Poster Team Colleague Featured Poster

You make it

} while (employee.equals(""));

and then evaluate the additional "20 errors".

The thing about the compiler is, it makes multiple passes through a code file, and if one pass finds an error, it will finish that pass, but not even attempt to make the other passes. And "simple" syntax proofs are the first pass. So, now you only see this problem. Once this one is fixed and the syntax proof succeeds, the compiler then makes the next pass, thereby finding your additional "20 errors".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

not quite, good point you made there. also good that you made me remember which one does what. ;)

Na. I said nevermind, because I had originally posted a larger response, then, right after I did it, I realised I had misread a portion of post (the part I had remonstrated about), so, of course, I had to delete it. ;)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Nevermind.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

also (this won't change the way the program functions), instead of saying "day = --day", you can say "day--".

Yes, that will change the way the program works. prefix is evaluated before the variable is used and postfix is evalutaed after. i.e.

int i = 5;
int j = i++;

i = 5;
int k = ++i;

Above j is 5 and k is 6.
So, as you can, it does change the way the program works.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Where in this part of the code have you defined Clock.

Stopwatch Clock;
			switch(c) {
				
				case 1: Clock.Start();break;
				case 2: Clock.Stop();break;
				case 3: Clock.Reset();break;
				case 4: Clock.Display();break;
			} //end of switch for calling stopwatch
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Grrrr :@ ........ yep that's correct :) !!!

Glad at least we agree on the tutorial he should use and about the null layout.

Oops. Didn't read your post carefully and missed the reference to the tutorial. Otherwise I'd have simply said "listen to him". ;)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

See http://java.sun.com/docs/books/tutorial/uiswing/layout/

It is almost always a big mistake to attempt to use the "null" layout (i.e. no layout). And for something like this, it is definately a mistake. Learn how to use some of the varying layout managers.

I wouldn't suggest you try it right away, but I use GridBagLayout extensively. It is the most flexible and controllable of all the layout managers, but it is also the most complex and the easiest to get wrong.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You have not set the layout for your JFrame, and so it is using the FlowLayout.

Uhmmmm, I believe the contentPanes of the top-level windows use BorderLayout, but that's beside the fact.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
new SearchResult(String s).setVisible(true);

Read any reference at all on Java and you will see that this is not the correct way to call a method. Method calls do not include the type with the parameter.

This is HelloWorld-level basic language semantics. I would recommend reading a lot of this: http://www.codeguru.com/java/tij/

So you did, after all, look at the code? Even though you said you wouldn't? ;-)

Just kidding.

I had the feeling it was this sort of mistake from the beginning, but I definately was not[/i] going to read all of that.

Edit: Ah, you didn't say you wouldn't, just hinted at it. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

String s = null;

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Loop until you have a valid value.

i.e.

String s;
while ((s==null) || s.equals("")) {
    s = JOptionPane.showInputDialog("Enter a simple infix expression: ");
}

Although you will have to define the parameters, that is just an example.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

First, the API docs, every Programmers best friend.
http://java.sun.com/javase/6/docs/

Second, the official Tutorials, every beginning Programmers second best friend.
http://java.sun.com/docs/books/tutorial/index.html

Third Bruce Eckels "Thinking In Java" 3rd Edition (the 4th Edition is not completely available online, yet).
http://www.mindviewinc.com/downloads/TIJ-3rd-edition4.0.zip

masijade 1,351 Industrious Poster Team Colleague Featured Poster

There is no direct way to "clear the screen" (except printing out a bunch of blank lines), and yes there is something to the effect of system("COMMAND");

Check out the Runtime and/or ProcessBuilder classes.

But the advice by jwenting is correct.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Why don't you try it and find out?

I'm sorry, but you claim to be jumping into Java quickly, on your own, because you already know a couple of other languages. Well, I need to ask, what "other languages" do you know? Because in that thread you had no idea what "static" was and in this thead, the method you are looking at is extremely self-explanatory if you have nearly any real programming experience at all.

Ezzaral commented: This is so crazy it just might work!! :P +11
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Use SimpleDateFormat to parse the entered info into a Date object, rather than making any assumptions about the numerical value of any month. 0-11 is how it stands now, on nearly every system, but they do not have to have those values. That is why Classes like SimpleDateFormat exist and that is why Calendar has static Fields for nearly every possible value (i.e. Calendar.JANUARY, Calendar.MONDAY).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Áre you talking about a SplashScreen (Google Java SplashScreen)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

javamail

masijade 1,351 Industrious Poster Team Colleague Featured Poster

To tell you that you should be careful of that all the time. Java is case-sensitive, when the OSes File System is not, it can lead to some compatability problems with other systems, or simply other execution plans (jar vs. directory). You've gotten bit by it once already, maybe you'll learn for next time.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No, on windows it works (at least when FAT32 is used, with NTFS, I don't know), it wouldn't work that way on nearly any other system.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

because you're awk statement doesn't produce anything. It sums, but does not print.

Edit: And I don't really know if it sums correctly. It's been ages since I've done anything with awk, so I'd have to look it up in order to be able to give you the correct syntax, and, truth be told, I don't really feel like it, right now. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well Mr or Mrs, that idea did not solve the problem, still the null error appears.

Anyway thanks for your contribution

Like I said, I didn't know if that was the problem that was causing a "null error", but that it was a problem that needed to be fix, if your "Icons" were inside the jarfile.

As far as your "null error" problem goes, it might help if you posted exactly which line the error occurs on, as well as the complete stacktrace of the error.

Edit: And if it is a null pointer error, the exception will tell you exactly where it occurred. Change that catch block to provide a stacktrace, as well.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

First of all, you should use

ps -ef | grep bash | grep -v grep

otherwise you sometimes get the process for "grep bash" as well.

Also, "$2" in a ps -ef command is the ProcessId, not the memory usage. The memory usage is not printed at all in ps -ef. You need to use the o option combined with "SZ" to get the memory size (but be aware that that is the "virtual" memory size, not necessarily the amount of memory currently in use by that process).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What "bothered" me, is that you didn't even attempt it. I have no problem what-so-ever with someone coming here and saying help me, this is what I tried, can you tell me what else to try.

That's what you did, at first. But, then I told you what to try, and you, essentially, said "I've never done that before (as if we didn't know that), and I don't what to bother myself to follow your instructions, just do it for me."

That, I have no patience for. And don't say you didn't say that, since there is no way to give an example on such a specific process without, essentially, doing it for you.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
InputStream is = getClass().getResourceAsStream(theUploadType+"Icon.jpg"));
BufferedImage bi = ImageIO.read(is);
is.close();
ImageIcon mybg = new ImageIcon(bi);

Now, what was so hard to understand about

You will want to use getResourceAsStream together with ImageIO.read(InputStream) to create a BufferedImage, then ImageIcon(Image) constructor

Does not the code above, follow exactly the process detailed below it, and in my previous post?

Was it sooo hard to at least read the API for the specific methods and Classes referenced that you just, absolutely could not manage to at least attempt it yourself?

Edit: P.S. There is absolutely no error handling in that "example", so you will have to do at least something yourself.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What I mean, is that if your "Icon" is inside of the jarfile, you can't access it using that form of the constructor. That form of the constructor can only be used if the "Icon" is a regular file, and inside of a jarfile, that is no longer the case.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

One thing I see is

ImageIcon mybg = new ImageIcon(ClassLoader.getSystemResource(theUploadType+"Icon.jpg"));

Is this "Icon" contained inside the jarfile?

If so, you cannot use this form of the constructor.

You will want to use getResourceAsStream together with ImageIO.read(InputStream) to create a BufferedImage, then ImageIcon(Image) constructor.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes.

I feel I need to qualify this remark.

That method should be final, because if someone extends your class, you will probably wind up with unexpected (and quite probably, for your class, catastrophic) effects if the method called from the constructor is overridden, as the overridden method would be called, rather than the original.

stephen84s commented: Great Info ... I have used it dozens of times never aware of this danger !!! +2
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Look at your constructors. You have a constructor that takes as arguments

String, String, char, boolean, Course, Course

but you are calling the constructor with

String, String, char, boolean, int, int

See the problem?

jasimp commented: What Problem ;) +8
masijade 1,351 Industrious Poster Team Colleague Featured Poster

AFAIK means, As far as I know. I haven't dug too deeply into it, it doesn't really matter. If you wish to know more about the way the language/jvm is suppossed to handle threads read the JLS http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html and the JVM specs http://java.sun.com/docs/books/jvms/second_edition/html/VMSpecTOC.doc.html.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because "str1 == str2 " is a String that you are printing in that statement.

As far as Comparator goes, read this http://java.sun.com/javase/6/docs/api/java/util/Comparator.html

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The garbage collector is called by the JVM whenever it is needed, and possibly periodically, otherwise. The gc() method is simply a request to the JVM to call the GarbageCollector, but ionly that, a request. It does not guarantee that the GarbageCollector will be run, or, if it is, that it will be run immediately.

Alex Edwards commented: Looks like you're on a roll tonight =) +4
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Thread's start method calls run.

The scheduling is handled by the OS (AFAIK).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

equals and toString exist in the Object class (which all Classes implicitly extend), so the class does implement them.

Also, == , when it comes to objects, compares there reference values (i.e. are they the same actual object). It does not compare there content (i.e. do they both contain the value "shobhit". If you wish to compare the content, use str1.equals(str2).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

See, javaAddict. That's all this guy is looking for, a free ride.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

jwenting wrote it last year :D

And that is exactly what I was getting at. ;)

I know what he means, as I am also a Sun Forums member. There are a few threads there like this where someone says "give me teh codez", and he never gets them, but then, usually every few months or so, a rash of new posts are added to the thread, and all of them are "new posters" that say "give me teh codez 2". There is one thread there (about some game "pujo pujo" or something like that) with thousands of respones and 90% of them are "give me teh codez 2". It's absolutley amazing. What's more, that one is so bad because one the members there said "post your email address and I will send you the codes, and make sure that all spammers also get it (since the forums are searched by spam engines, anyway)" and after that the post count just exploded, even though he clearly spelled out that he only made the post in order to give the spam engines something to find. :D

masijade 1,351 Industrious Poster Team Colleague Featured Poster

"dd/MM/yyyy" not "dd/mm/yyyy"

Case makes a difference (m is minutes in hour, not month in year).

See http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html

Always read the API docs for the class in question, first.