~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

Since this is yet another 'gimme a project' thread with no real value, locked.

~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

> Any body please send me a complete java project on

Read the forum rules regarding the same; we don't provide free code. Put in some effort and get back if you face any problems. Locked.

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

> Why?

Simply because end users of your application need no frigging stack traces. ;-)

It also seems to indicate that the programmer isn't very clear on the kind of contingencies that can arise in the application and he plans on getting away by either having a generic catch-all block or having main() method throw an exception in its declaration. Then again, the granularity and rigor with which exception handling is implemented depends on the scale/scope of the application in consideration so YMMV.

From a professional development viewpoint, exceptions are usually caught and an appropriate course of action is taken; if it's a valid business scenario which has caused the exception [i.e. a business exception], the user is presented with a meaningful message and a resolution for the same if possible. If it's an exception which isn't caused due to the violation of business scenario and can't be resolved by the user, the exception is logged at the same time presenting the user with an appropriate message. And finally comes a catch-all block which is guaranteed to catch any sort of nasty application behavior, log it and present the user with a generic "sorry for the inconvenience" message.

Of course, when developing frameworks and libraries, a few other things need to be kept in mind when designing the exception hierarchy and exception handling mechanism, but yes, that sort of sums it up. :-)

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

What have you got so far? Help will only be rendered if you show some effort on your part. Since the specification looks pretty hefty I am sure you are good to go with Java and JEE.

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

There is a better way of doing the same thing which encodes the URI component to avoid all such problems:

encodeURIComponent("a,b,c"); // a%2Cb%2Cc
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Please help. . I'm just a beginner. . Thanks!

Start by reading the stickies at the top of the forum to get started with Java.

The forum rules forbid / discourage ready solutions to the problem posted by members and help is rendered only if an effort is shown from your side.

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

> nobody here expects every poster's English to be without flaws,
> but since English is not my 2nd or 3rd language (4th, actually)

Just because you can do it doesn't mean everyone can; each person has a different learning curve, level of perception etc. etc.

> I agree, some of my posts can be rude, but considering the
> amount of topics here with the classical "how to create .exe files
> from projects"

Disagreements are a part of forum discussions but name calling and sarcasm in the guise of correcting is something the rules don't permit. Also a wrong answer doesn't automatically qualify a post as being the bulls eye for sarcasm/negativity.

> but the sollution here seemed a bit like using a pitch fork to eat a
> bowl of spaghetti:

Then try to make him understand how to actually eat a bowl of spaghetti instead of stuffing the pitchfork down his throat, rendering him unable to eat anything his entire life.

> so yes, I do reply then with a comment that might seem as
> 'putting him down', since the soft approach doesn't really hand
> out the most refreshing wake-up call.

As an example, just because I hate someone doesn't make killing that person a logical choice. In the same manner, just because I feel something is a lost cause doesn't make breaking the rules a logical choice.

> I …

verruckt24 commented: I'm the kinda person who rather hates persons like the mods etc., but dunno there's something in the way you explain anything, that we feel we ought to obey and say 'Yes we'll do it'. Keep it up. +2
stephen84s commented: I hate you, you manage to persuade me almost everytime. +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> to prove my stance being correct here

Let me say this once again; the stance of posting sarcastic/hostile comments is never the correct one. Normally hostile attitude adopted towards a forum member is rewarded with an infraction; something I try avoid giving at all costs. Maybe this stance is causing other people/forum members to adopt an easy going attitude regarding moderators / forum rules?

And regarding the tone adopted by the poster, I have had similar experiences with people having English as their second/third language; the thing they try to convey ends up being different than what they end up writing.

Like almost every forum rules out there states, if you think you have nothing more to add other than flaming the poster, please avoid making that post. Rather than bringing the poster on the right track, it might have the effect of turning a perfectly fine discussion into a flame war.

stephen84s commented: Hey ~s.o.s~ you dint mention whether the mod hat was on or off :P +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

<mod-hat-off-mode>

I am *really* concerned with this recent stance taken by the regulars when dealing with posts which given out wrong information. It feels really bad when I see replies/comments along the lines of:

roseindia, are you kidding me???? One awful place they love to show-off most terrible solution

useless, irrelevant and dare someone call it even "information"

Useless information

That is the worst advice ever. To encourage someone to go all this trouble, when they already have a jar file that can be run. You are practically destroying the hole concept of writing the program in java.

so, genious, how many of your favourite sites did you convert to an .exe lately?

Great, just great, all I see is pointed words dripping with sarcasm. I'll tell you what you just did. Your comments didn't enable him to learn, they just discouraged him helping out people in the future with the fear that he would again be criticized.

So I ask you all, were you this smart/good to go with Java when you started as a beginner, would it have been wrong on your part to refer to roseindia when it was the first tutorial which came up from a web search, were you all smart enough to realize that what roseindia gives out is bad on all counts? Isn't this just *collective* knowledge you gained by being told by others / visiting the forums?

Does this poster have that kind of history of ignoring advice …

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

> When will ad makers realize that their stupid tricks intended to ruin
> attempts to navigate make people mad at the sponsors?

Probably never since everyone who surfs the web is not as er... smart as you.

You have two choices:
- Get some addons installed so that this doesn't happen
- Make sure your click carefully when browsing or file a bug with IE / Firefox for not *blocking* ads by default or get approval to have addons installed or file a complaint against the ad agencies or ....

~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

The number of requests is not the issue here; after all, web servers are tailored to handle several concurrent requests simultaneously.

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

Read the stickies at the top of this forum; they contain all the information required for a beginner to get started with Java - from scratch.

~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

"Apathetic Harbinger of Sorrow"

That's it; I am not buying the book...

Nick Evan commented: Haha :) Great post +12
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> its 255 chars isnt it?

No, it isn't.

> where ans could be upto 10000 charecters

I have been successful in sending more than 33,000 characters when posting data [Tomcat 6.0] both asynchronously and synchronously using both IE and Firefox.

So like I had previously mentioned, there is something definitely wrong with your configuration or code and not anything related to GET or POST limit.

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

> So I'll be grateful if anyone can help me with some sample code in
> Ajax with Java related technologies.

Ajax is a set of technologies and hence doesn't depend on a single language for its implementation. Ajax is simply a asynchronous request sent by the browser using the inbuilt XHR object to the web server and getting back a textual response in a suitable data format[XML, JSON etc].

The way the web server handles the request, processes it and responds to the request is left to the implementation you desire. But if you are looking for a Java based solution for handling Ajax in your JEE web application, the above post is a good starting point.

~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

If you are developing in Java 1.5 consider using generics in which you can make toArray() of Set return an array of T[] where T is the type of element you have stored in your Set.

Set<String> s = obj.someMethod();
String[] sArr = s.toArray(new String[s.size()]);

Alternatively, you can create a TreeSet out of your given Set which guarantees that its elements are always ordered.

Set s = obj.someMethod();
s = new TreeSet(s);
// s now contains elements sorted according to their
// natural ordering

Also, if you are in control of the method which returns a Set , you can modify the logic to store the elements in a TreeSet from the start which will do away with the need of performing a sort later on i.e. sort as you add.

./sos

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

> As I said I'm new to java

Then you should try reading the stickies at the top of this forum and get your Java basics cleared up before messing around with complicated stuff like GUI etc.

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

You need to check if an integer can be read from the Scanner before actually reading it; the same applies to any kind of token, always. A proper mix of hasNext() and hasNextInt() provides a relatively better and appropriate way of implementing the given functionality. A sample snippet is as posted:

import java.util.*;

public class ScannerTest {

  public static void main(final String[] args) {
    new ScannerTest().startTest();
  }

  public void startTest() {
    Scanner in = new Scanner(System.in);
    int i = 0;
    while(true) {
      System.out.println("\n\n1. Say hello");
      System.out.println("2. Quit");
      System.out.print("Enter your choice: ");
      System.out.flush();
      if(in.hasNext()) {
        if(in.hasNextInt()) {
          // the next token can be safely converted to an int
          i = in.nextInt();
          if(i == 1) {
            System.out.println("\n*** Hey there! ***");
          } else if(i == 2) {
            System.out.println("\nThank you for wasting your time.");
            System.exit(0);
          } else {
            System.out.println("Invalid choice.");
          }
        } else {
          System.out.println("Enter a valid number [1 or 2].");
          in.next();  // not a valid integer, skip this token
        }
      }
    }
  }

}

You might consider using a BufferedReader with a custom string processing method to have greater/absolute control over your parsing logic or if you feel that the Scanner API is dragging you down.

~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

i have a homework. do a program using java that will ask a user to input a infix expression , and the program will convert it to postfix expression...
help!!

Read the forum rules and announcements; help is provided if and only if an attempt is made by the poster. Give your assignment a try and post if you have any problems. Read the stickies at the top of the forum to get started.

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

Though I agree with you on a logical note, the rules need to be followed; I am sure if you had your mod hat on and were given the responsibility of enforcing the rules, you would feel the same way.

> And anyway as you said, we always have you to do the clean up

Damn, so much for being nice ;-)

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

*sigh*

And what do you all think happens when the OP *does* end up with something? Wait, let me guess, I would have to delete the off-topic posts and preachings to make this thread seem on-topic, right?

Though we all agree that a few deviations/off-topic discussions foster a healthy forum environment, way too many off-topic posts, preachings and taunts dilute the topic in consideration and gives the forum a bad name.

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

I guess it doesn't do what the OP is expecting:

Retrieves the Map object associated with this Connection object. Unless the application has added an entry, the type map returned will be empty.

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

To be of more help, you will have to provide me a bit more details on the kind of application you are building. Where exactly is the query containing Java data types coming from? Why not normal queries?

The meaning of my previous post was pretty simple, let's assume you have the entire query in a single string then all that remains to be done is to use replaceAll() method. The regular expression required can be created by iterating over the map which contains the java data types to SQL data types mapping.

I would like to see an attempt from your side before providing a sample snippet. :-)

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

Ah, I misread the question.

Anyways, use the String companion mutator class i.e. StringBuilder to process the line read since Strings in Java are immutable.

StringBuilder buf = new StringBuilder(line);
// Process this buffer character by character, ignore whitespaces
// and capitalize the first non-whitespace character.

Look into the Character wrapper class for utility methods to convert a given character to uppercase.

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

Consider using a mature Javascript library like jQuery or Prototype which abstracts away almost all browser inconsistencies and quirks. That way, you would be able to build web applications which work on almost all browsers out there.

~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

> For that, I need to map all the java datatypes to sqltypes.

This largely depends on the database engine in consideration and is normally taken care by the database driver.

If the database to be used is known in advance, a simple global search and replace should do the job. For additional flexibility, consider using a map to store the mappings which can be loaded from a properties file.

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

> writer.write(line); writer.write(line.toUpperCase()); Since you are reading in a line from the file in a String, consider looking at the java.lang.String class documentation.

~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

> String Name = new String (employee); Strings in Java are immutable, you don't need to use new String() , ever.

> if (name = "Mark Jones") I think you should try reading the basic Java tutorials hosted by Sun and do a bit of practice.

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

length() method returns a long [primitive] and you are trying to dereference it by trying to invoke a method on it. Use use the == operator for comparing primitives.

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

Either make the String array as a member of ReadFile or make the method isReadFile static. Anyways, if your code looks the same way as you have posted, you are missing the invocation of isReadFile in main() which actually initializes the two dimensional String array.

If all you need to do is to read the contents of the file once, there is no need to maintain static member variables or impart any state to the ReadFile class; just make it a utility method and you should be good to go.

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

Can u people help me in getting java code to transfer files (FTP) over the LAN.Give me the complete code for this.

I wan that a FTP request to be send to the desired host and if the host accept the request then the browse menu be opened that allows the host to select the file to be transfered.Then by clicking on some button the FTP operation should be completed. The ttransfered file should be saved in an appropriate folder on the client side.

i will be greately thankful to u people.

If this is a homework or self improvement assignment, consider at least giving it a try by going through the basic networking tutorials on Sun and the source code of the open source libraries out there.

If not a homework, there is no need to look for a *Java code* to do this; there are many free and open source FTP clients out there which can aid your cause.

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

Hello, have a good day everyone. I am confused if what elements are to be inserted in a queue. Are only numbers can be inserted in a queue? Are letters or word(e.g."Subject") can be inserted in a queue? Thank you ahead everyone. Have a nice day.

Learning by doing is the best form of learning; a small code snippet, a simple web search or the description from the Javadocs would have answered your question. Even though it takes a bit of time, you gain a lot more knowledge than reading ready baked answers. :-)

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

People are normally averse to opening attachments; it would be better to paste the *relevant* piece of code and describe a *single* problem at a time rather than confusing the reader with a lot of details.

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

> I don't know which class to use.

Use the Scanner class to read the textual data in a line oriented manner. Create your own input processor class which operates on a given line and creates a class instance which represents the given business entity or a primitive depending on your file format. Add the returned entity to a collection. Rinse and repeat for each line.

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

hello guyz,,i just want to ask if you know a site that have a free ebook that would explain best the data structures..we have a problem to code..and it is about queues,,and sorting,,and i hope to find a best ebook that will explain best about the sorting and the queues,,,thanks ahead guyz,,,,

Read the stickies at the top of this forum, it will keep you busy for quite a while; and yes, like Ezzaral said, putting in a bit more effort would be beneficial for you as well as us.

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

can anyone plz help me. i m not able to compile source code.the problem is javac not recognised as internel or externel command.

Consider doing a simple web search for the exact error message and 9 times out of 10 you would surely land up with a solution. It would be quicker for you and a time saver for us.

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

Why would you want to dump a byte array in a log file? Anyways, use a FileWriter in append mode and if it is *really* required, write out the byte array as a string [by looping over individual bytes and converting them to their String representation; use a StringBuilder].

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

> Oh come on.
> You were not born Programmer

Sure he wasn't but I don't think this would have been his reply when pointed in the right direction. Of course it's a different thing if you were just trying to get over this assignment...