~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> However, the program runs without any problems in JCreator.

Check for possible hardcodings in your Java source files and the .bat files. Do a text search for the old directory name in your project directory and you might just stumble upon something.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> java.lang.NoclassDefFoundError

You need to show us the command line invocation of `java' which you are using to run your program. If your class 'Z' is inside a package 'my.pkg' inside the directory 'test', you need to use a command like:

c:\test>java my.pkg.Z

Read the links specified in the forum sticky for a detailed explanation.

>I got the file to right with that method, but with out the serialization
>package working I cant really see if the file size is different and we
>have improved performance.

Huh? Improved performance?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

defaultWriteObject is equivalent to the default serialization performed in the absence of a writeObject method and is normally used in conjunction with custom writes to persist transient or extra data. Hence you might want to resort to something else.

One solution might be to grab the contents of the entire binary tree in a List, serialize that list using ObjectOutputStream.writeObject in the writeObject method, read the same and populate your tree.

Here I am assuming that the elements inserted in the BinaryTree have natural ordering i.e. implement the Comparable interface.

> I see a lot of views, but may be I am not asking the question right.

Consider using code tags and proper indentation when posting code.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Yes, I am taking a class

You should convey to your professor the problems you are facing and ask him to help you out even if it means spending some extra time for it. One-to-one help is far better than trying to understand the same by asking on message boards.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Hi, i have made those changes

It seems you haven't since I still see the call "MM_callJS('order(this.form)')"; re-read reply 10.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Have you made the fix suggested in my previous post? Re-post the entire code and point out the line which is having problems.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> MM_callJS('order(form1)')

Replace the above with order(this.form); .

> and i also change the form1 in my function to this.form

Like I mentioned, change form1 to this.form only in onchange and onclick handlers and not anywhere else. The form1 in your function is the form reference which is passed as an argument to the order() function.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> But it is giving error that x is null. Can any one please correct it?

Because the `style' property is only set when inline style sheets are used. To get the style details of the element whose style is set using linked or embedded style sheets, you need to put in a bit of effort. Read this.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I already provided the fix in my previous post. If what you posted really is your code then you shouldn't have problem understanding the fix I suggested. Anyways like I mentioned, you need to replace `form1' with `this.form' in your event handlers: onclick & onchange.

> Would u kindly provide me a code snippet as to how it should be
> done, i am really lost

Sifting through the entire code to fix the issue would be way too time consuming; you need to start learning Javascript using the links I provided.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It is only in IE[and some other buggy browsers] that the NAME or ID attribute of an element represents the element in consideration; which actually isn't correct. You actually need to grab the element in consideration by either traversing the DOM [getElementById] or using the form reference each form element holds.
- Replace the `form1' with `this.form'
- Move the entire code snippet in the onchange handler and then invoke that function with `this.form' passed in to that function

Also, you shouldn't use eval; there is always a better way of doing things. Read:
http://www.jibbering.com/faq/#eval
http://www.jibbering.com/faq/faq_notes/form_access.html

As mentioned earlier, read the forum for the use of code tags as many people might ignore posts with code without code tags.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Sifting through that massive piece of code would be time consuming. If developing on Firefox, look into the Firebug addon which adds capabilities like Javascript debugging, error detection etc. Look at the errors which pop up in the Error Console; it will point you to the exact source of the problem.

Also, use code tags when posting code so that its easier to read; refer the forum announcements for more details.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Why is it too hard to find a girl friend who is as smart as Narue(dont
> take this one seriously )

Because for you "Life is much simpler without women." :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I know that you do 6.83783 * 10^3 as 6.83783E3, but how do I do
> that number times 10 to the negative third? 6.83783E-3

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> is there any book from which i can learn net beans

The best way to learn an IDE is to start using it to develop projects; learning while doing is probably the best way to do things.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> how can I do it?

By reassigning the out member of the System class using setOut(PrintStream) .

System.setOut(new PrintStream(new OutputStream() {
  public void write(int b) {
    // NO-OP
  }
}));

Or simply redirect the output to a file or /dev/null [unix] when running the Java command:

java your.pkg.your.class > log.txt
java your.pkg.your.class > /dev/null

The kind of functionality you are seeking i.e. conditional enable/disable of print statements and redirection to a different source are screaming out for the want of a logger library. Look into Log4j for more details.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Make sure your database/table is created with Unicode as the encoding. Refer the Postgresql forums/documentation for more details.

Also try getting the connection with the URL which also specifies the character set explicitly.

jdbc:postgresql://localhost:5432/testdb?charSet=YOUR-ENCODING-HERE
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

is there any method or class for getting the datatype of a variable????

After the variable is declared i must get the datatype......
hw can i do ....
any ideas??

You can get the type of any member variable or local reference type variables using reflection; for local primitive variables, AFAIK, you can't get the type.

import java.lang.reflect.*;

public class Test {

  private int i;

  private String s;

  public static void main(final String[] args) {
    for(Field f : Test.class.getDeclaredFields()) {
      System.out.println(f.getName() + " -> " + f.getType());      
    }
    String s = "test";
    System.out.println("test: " + s.getClass());
  }

}

Maybe shedding a bit of light on what you are trying to achieve here would help us coming with more to the point suggestions.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Read this.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Simply run an infinite while loop, wait for user input, process that input and make your decision accordingly.

// create Scanner etc.
while(true) {
  if(in.hasNext()) {
    String str = in.next();
    if(str == null || str.trim().equals("no")) {
      System.out.println("Thank you");
      System.exit(0); // or break;
    }
  }
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> The public type global must be declared in its own file.

Make sure the name of the file is the same as your public class/interface; also make sure a single file doesn't contain more than one top level public class / interface.

> Cannot make a static reference to the non-static method
> publisher() from the type trying

publisher() is an instance method and can only be invoked from another instance / non-static method.

Reading the stickies at the top of the forum is recommended.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> but when I start the client nothing happens

Put a few debugging statements to monitor the entire conversation and post where exactly your program hangs. For e.g. print out a debugging statement to the console when the server receives a client request [i.e. after accept()] and so on. Alternatively, if you are using a good IDE, it should be pretty easy to trace the entire client server communication using the in built debugging capabilities.

Also make sure that when you are using buffered streams, don't forget to flush them after you are done with all the writing since a write on the buffered stream doesn't necessarily mean the data is written to the underlying stream.

tuse commented: thanks! +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

IMO Scanner is much more than just another I/O class with a pretty interface/API; it has advanced parsing capabilities which attempts to remove the utility class most programmers create to process the strings read in by a normal reader. It is pretty much capable of reading and performing complicated processing on strings irrespective of the source [Strings, InputStreams, Readers]. The feature of skipping/locating patterns based on regular expressions is powerful in itself.

On the other hand, the API specifies that the BufferedReader class *should* provide buffering capabilities, something not mandated when implementing a Scanner .

To conclude it all, I still end up using BufferedReader and my custom string processor when reading and processing textual data. Nothing against Scanner mind you, just historical reasons. :-)

javaAddict commented: That's the comment I was looking for +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

>Now I do not wish to be rude here but if you use common sense I
>guess any one can decipher that you cannot check whether a value
>is negative or positive BEFORE YOU HAVE EVEN READ IT from the
>console.

That's an excessively harsh post there; I would really recommend against replying if you tend to lose your cool over silly/trivial mistakes by the OP.

> That is why I asked for help, had I known the right place to put it

Programming is much more playing dice; questions like "I don't know where to put XXX" gives off a general impression of you not putting in the effort required by the assignment.

If you find a post offensive, consider reporting it and moving on with your question rather than involving yourself in the debate and making the thread fall into the deep pits of flamewar.

> All I asked for was some help, which I thought was the whole
> pupose of this site, but you have to be a jerk about it.

That's a pretty bad attitude for someone who is asking for help and would only result in people not responding to your queries. After all, what you are asking for is free help; if you like it, take it, if not, leave it, simple.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

What exactly were you expecting when you declared:

double Math.calcFV = p * Math.pow( (1.0 + r/100), t);

Since a '.' isn't a valid character when used to name variables, the compiler sees this as:

double Math(something-unexpected-when-it-should-have-been-a-semicolon-to-end-the-declaration)

Hence the given message.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Where 'this' as mentioned above refers to the current object. Since
> static members do not belong to any particular object/instance as
> such, for them 'this' does not make any sense.

...but is still valid though is ignored. It is completely legal to invoke a static method using a reference though misleading at best.

> So, when you write calcFV() without mentioning any class/object
> name before it, java assumes that you are referring to the same
> class' method/variable and changes the call to this.calcFV() .

Not always true since if the method by the name calcFV() is not present in the class hierarchy, invocation of a static method by the same name is attempted [in which case there is no `this'] or a compilation error with no such method exists is spit out.

> Now towards the explanantion of your error. In Java there is a
> 'this' variable that stores a reference to the current object.

Or put in a more detailed manner, a reference to the instance currently executing the given method [the method which is present on the top of the callstack of the currently executing Thread].

> So when you call a non-static member variable/method from a static
> method, the 'this' variable cannot be used for dereferencing as
> mentioned above the JVM has no way of knowing which class'
> method/variable you are referring to

…

javaAddict commented: I liked the: 'Expecting NPE' comment. Didn't know it was possible +5
verruckt24 commented: Got to know loads of things. +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> i just thought you guys would of liked a challenge lol

I have got enough challenges in my daily life, I guess I'll just pass. :-)

But don't give up hope, who knows, masijade might just end up dropping in a jar file here with a "meh" look on his face. ;-)

caps_lock commented: thankyou for the hope! +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

so just to add more detail because theyre may be confusion

Im basically trying to get files with equal file size first, then im trying to put those in an array, then the files in the array need to be compared possibily by length (bytes) (not file names but files contents), the comparison need to be made maybe by binary contents or by generating an MD checksum which ever ones easier.

Like it has already been mentioned by masijade, you have to make a stab at this and post again if you have any problems. Just putting in random conditional statements here and there won't cut in. Since you already seem to know the logic, you can at least try implementing it.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> int generator1 = generator.nextInt(20)+1/2;

Operator precedence anyone?

> /*
> * To change this template, choose Tools | Templates
> * and open the template in the editor.
> */

I am surprised how someone can churn out such an unformatted code even after using an IDE / advanced text editor.

> class Math12 { /* */ }
> class Math5 { /* */ }
> class Math7 { /* */ }

The very fact that multiple classes are created which do the same thing is a clear indication of design problems with the application. Consider customizing the class instance by having constructors/factory methods.

...and many other things.

If your friend really wants to learn, tell him to start some serious reading. A lot of beginner resources are mentioned in the sticky; starting with the Java beginner tutorials ain't that bad an idea.

stephen84s commented: You must have really put in some effort to read all that <Ugh> code +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Though I don't do standalone application development using Swing, a few obvious comments.

> Class.forName("com.mysql.jdbc.Driver").newInstance(); .

You don't need to do this for every invocation. As soon as the Driver class is loaded, it registers itself with the DriverManager and that's it; no more Class.forName() required. Also, you don't need to create a new instance, just doing Class.forName() is sufficient.

> String computer = ""; .

Try to avoid this. String computer = null; is good to go.

> getConnection("jdbc:mysql://IP_ADDRESS:3306/DB", "USERNAME", "PASSWORD"); .

Don't use magic numbers/literals in your program. Either load these configurable parameters via an external resource [properties file] or at least move them to a separate class/interface as constants and refer them throughout your application.

> public void Refresher() throws SQLException .

Follow Java coding conventions; don't use uppercase characters for method names. It is a bad programming practice to expose checked exceptions to your client[given that the method is public]. Since a SQLException is almost always unrecoverable, catch it and either rethrow it wrapped in your own application specific Exception class or just log the exception for debugging/troubleshooting/analysis purposes.

You never release your database resources! You need to close the ResultSet , Statement and Connection object. Read the JDBC tutorials for more information.

public void some() {
  Connection conn = null;
  PreparedStatement pStmt = null;
  ResultSet rs = null;
  try {
    try {
      //grab connection
      // use statement and resultset
    } finally {
      if(rs != null) …
Ezzaral commented: All good suggestions. +16
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> but i dont think it has had any change in the list of results brought
> to the terminal window

And what were you expecting by checking if the file size is less than or equal to one byte?

Maybe posting/uploading a virtual directory structure along with the expected output might help others in collaborating for a better solution.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Detection of duplicate files isn't that simple; refer a similar thread. If that's not what you intend, a bit more explanation is needed.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> How at that point is it not possible to figure out that sending a PM
> to xxx will fail?

Technically, it's pretty much possible. I guess what you speak of is a default vBulletin behavior and hence remains that way. Though such things don't happen very often, it's but logical that such a check be in place.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> but whats problem with this syntax?

The changes to internal implementation of the model [business logic + data] which affect the view which shouldn't be the case. Also a design which employs separation of concern is far more easier to maintain, change and troubleshoot.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you want to execute an action [i.e. send a HTTP request] without reloading the page, you have two options:
- Remote scripting via hidden IFRAME
- Using the XMLHttpRequest object to make async requests

./sos

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A bit more explanation here.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Checking out that huge chunk of code for Javascript errors is quite a herculean task.

To ease your development, I would recommend that you carry out your development testing in Firefox and make use of the excellent addon "Firebug" which provides features like Javascript error notifications, debugging facility and much more. If there are any Javascript errors, the error console will point out to you the exact line on which the error has occurred.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The check for email == undefined is superfluous since a value of text form field, if it exists will never be `undefined' or `null' but always a empty string if nothing was entered. You should rather check the return value of getElementById() so that you don't end up trying to access the `value' property of something which doesn't exist. Also the above validation can be easily bypassed by entering just whitespaces. Maybe a trim is in order?

function validate() {
  var e = document.getElementById('emailId');
  if(!e) return false;
  var txt = trim(e.value); // here trim() is a custom function
  if(txt === '') {
    alert('Please enter an email id.');
    return false;
  }
  return true;
}

./sos

kanaku commented: he owned me +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If that's your requirement then you need to change your original code which is as of now setting the onmouseover property of A elements and not LI elements in which the A elements are nested i.e. instead of thisLink, the element in consideration should be thisLink.parentNode.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A pure CSS solution:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta http-equiv="Script-Content-Type" content="text/javascript">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Example</title>
    <style type="text/css">
      li a {
        background-color: #abc;
      }
      li a:hover {
        background-color: #def;
      }
    </style>
  </head>
  <body id="bdy">
    <div>
    <ul>
      <li><a href="http://www.google.co.in/">Google</a></li>
    </ul>
    </div>
  </body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I need a bit more background on the requirement/problem here as in what is the source of the XML you are talking about? Is is shipped over the network using an async call in the form of AJAX or read from an external file? Also posting some sample code which others can hack on and reproduce your problem might just help in faster resolution since "works differently" is kinda difficult to pinpoint given there is no context established in the form of a code snippet.

Also, given that XMLSerializer is specific to Gecko based browsers [not a standard], reading the API or asking in the Mozilla forums seems to be your best bet.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Because selectedIndex can't be a alphabet; it has to be numeric; more specifically long.

It would be better if you just passed in `this' and got the value selected using:

function showSomething(elem) {
  var val = elem.options[elem.selectedIndex].value;
  // process the value
}

// in your markup
<select id="choice" onchange="showReg(this);" size="4">

Make sure the intrinsic event handlers are in all lowercase as mentioned in the specification i.e. onchange instead of onChange . Also make it a practice to assign a `name' to all form elements because AFAIK values of elements without a name aren't submitted.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Whenever possible, you should always use the W3C
'document.getElements...' methods rather than collections such as
document.links, .forms or .images

links is a standard property of the document DOM element. It would be interesting to know the reasons of preferring the long winded and probably expensive document.getElementsByTagName() route.

@xander85:
AFAICR, there is a pure CSS solution which perfectly fits your scenario. I can't think of a better solution than letting the rendering engine do all the heavy lifting for you rather than you doing it yourself. The CSS solution has the advantage of working even when Javascript is disabled. Maybe something like:

li a {
  background-color: #999;
}
li a:hover {
  background-color: #333;
}
xander85 commented: I should have thought of that, THANKS! +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Is it possible to pass a large parameters with the POST request ?

Ideally yes, since I find no mention of a limit in the HTTP specification. Practically, it depends on both the browser/user agent and the server accepting the request, which again should be enough for your needs. Are you facing any problems as of now?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A constructor is a special construct of the Java programming language which can be loosely thought of as a method with the same name as that of the class for which the constructor is meant with *no* return type and which will *always* be invoked when an instance creation is requested.

A no-arg constructor is a constructor which doesn't take any arguments.

public class Person {
  private String name;

  // no-arg constructor
  public Person() {
    this.name = "default";
  }

  // a constructor with one argument, name
  public Person(String name) {
    this.name = name;
  }
}

In case you fail to provide a constructor, a `default' constructor is automatically provided to you which *always* will be a no-arg constructor.

I would recommend you first need to read the basic Java tutorial hosted on Sun and those posted in the stickies at the top of this forum since all these questions are already answered there. If you really want to learn, your questions should *not* be of the form "What is XXX?" rather "Given that XXX is YYY, I really don't how ZZZ fits the picture".

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If your project was set up in Eclipse, the "Restore from Local History" option might work out for you; it's worth a try.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> How can I achieve this ?

In case of a GET request, the data is embedded in the query string while in case of POST request, it is passed as a argument to the send method of XHR object. Read this.

> Is POST method can read a large string from any html element
> using AJAX ?

You seem pretty confused here; what exactly do you mean by read a string from HTML element using AJAX?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The given JSON can be simplified as:

var json = [
  {"zip" : "27603", "city" : "Raleigh", "state" : "NC"},
  {"zip" : "25071", "city" : "Elkview", "state" : "WV"}
];
for(var i = json.length - 1; i >= 0; --i) {
  var o = json[i];
  var zip = o.zip;
  var city = o.city;
  var state = o.state;
  alert(zip + " " + city + " " + state);  
}

If using your original JSON representation:

var json = {"results": [
  { "zip" : "27603", "city" : "Raleigh", "state" : "NC"},
  { "zip" : "25071", "city" : "Elkview", "state" : "WV"},
  ]
};
var arr = json.results;
if(!arr) return;
for(var i = arr.length - 1; i >= 0; --i) {
  var o = arr[i];
  var zip = o.zip;
  var city = o.city;
  var state = o.state;
  alert(zip + " " + city + " " + state);  
}

You can wrap this entire thing in a function which will analyze the JSON string fetched, iterate over all the city names and execute a given logic accordingly.
To verify the validity of your JSON, use JSONLint.

Also, I would recommend using the parseJSON method found in json.js, instead of eval .

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I don't think that anyone in academics would agree with such a
> broad statement.

...something which I was expecting all along. ;-)

JFTR, how many good java programmers have you seen who are not good with the tools they work? And how many programmers have you seen who struggle with the basics of Java programming language but still are focused on learning the tools? As for me, none of the former and a lot of latter.

> but knowing how to properly use your resources is probably just
> as important.

From a practical standpoint, anyone can learn every feature in Eclipse related to Java development in a day; so yes, tools are important but not something which need focus, you just work in them and their usage becomes pretty much second nature. This is something which can't be said about understanding the language basics.

But it seems almost everyone in this thread agrees that basics come first, tools second, so now, back to helping out the OP. :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> whenever you access a method, it gives you a summary of what the
> method does, as given in the API

...so do the online java docs. But in most of the cases we end up with a bunch of CTRL + SPACE programmers who find it too troublesome to even remember the method signatures of the most commonly used methods out there.

As someone who earns from programming, I find such tools to be really useful in boosting ones' productivity and getting the job at hand done faster, it can't be denied that knowing the basics of the language you develop in of prime importance. I am pretty sure none of us would want to hire someone who is completely lost without an IDE; after all, it's a Java developer we are looking for and not just a Eclipse/Netbeans/IntelliJ user.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> although I have this "izraz.txt" file in the correct location

If that were the case, the said exception won't be thrown by the Java runtime. The solution to this issue depends on how you are executing your program. Are you using an IDE, or is it a command line invocation of `java' or are you using any build tool like Ant?

A simple way of knowing your current working directory is to create a blank file with some unique name [e.g. java-sucks.txt] using your PostFix program and search your file system for that file; the location where you file was created is where you should have your `izraz.txt'.

BTW, you still have parsing logic in main() and dynamic string creation is better done using StringBuilder than using += repeatedly inside a loop.