stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Any specific reason why you want Java to do that ?

However According to me it doesn't seem possible, as your browser is a completely different "process" just as there would be a separate "java process" in which your program would be executing.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

He wants a custom error message so it seems like a better idea

You can set the "message" for most (if not all) inbuilt exceptions including the IllegalArgumentException (for whom this constructor can be used which was also mentioned by Ezzaral in his second post).

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

<Ignore>

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I tried 3389 (RDP Port) that failed, and yet Remote Assistance works.

Now that would mean the specified service is already using that port, so if a port is already in use, you application cannot use it for listening, have you tried turning remote assistance off.

8080 Also failed, and just for giggles

8080 is normally used as a port for intranet websites so many ISPs tend to block this port for receiving traffic from outside.

when I tried 6112 (A port I forwarded to play warcraft 3) and that worked.

Here you most probably did not have WarCraft running and thats the reason why I am guessing your application worked.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Define your own exception handler and use try/catch

Most probably you mean define his own (custom) exception class, but this would be just an overkill.
Ezzaral's suggestion of throwing an IllegalArgumentException for me hits the nail on the head.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

@ejosiah
Both those options were already covered in my post.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Here are a few examples on alternatives how to read Input from a Console :- 1,2,3.

Considering your case you might especially like the third link.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

No, We are not hiring now anyways. ;)

Not to mention the hell of a first impression he has already made.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I cannot see a main() method in the code that you have posted, also you have not made your JFrame visible using the setVisible(boolean) method.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

How to get the value from a hashtable irrespective of its case...

Would you care to mention what does your Hashtable contain or do I have to find that out from my crystal ball.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Strange even I had the Notion of HDDs being faster than SSDs but not only the Wiki even googling says otherwise.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

rather new to java

I am using the Netbeans JDE in creating a Java GUI.

If you are new to Java then do not directly use GUI designers provided in NetBeans, you might get your initial form designing work done faster but when it comes to do some actual coding with these UI components you will find yourself paralyzed. So begining use a minimalistic IDE (eg JCreator LE) which allows you to just compile and run your code and nothing else (not even code completion). And in case you run into any problems or want to look for methods provided by the built-in java classes refer to the javadocs either online or they can be downloaded from here.

Now as far as your problem is concerned, If I am not wrong you must be having some sort of "button" so the user can tell your application to convert whatever value you have in the JTextField to the specified currency, So over there itself you can put a validation check to ensure whether the user has entered a proper numeric value or not. You can just shoot a getText() method on your JTextField and using the matches() method of the String class in combination with regular expressions, to check if a valid input has been specified.
Alternatively you could also implement the KeyListener to check the value in the JTextField as it is typed on …

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Yeah, free isnt free, there is total cost of ownership, which in some cases, isnt much less (or even more) with OSS.

Now what does this imply ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

not stalking at this stage, a little bit curiousity..

You mean preparing to stalk. ;)

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

client machine to a server machine

Ever heard of Sockets, and also you do not need to send 1's and 0's you can send entire objects by using serialization (Some resource on serialization -- 1,2,3,4).
Here is a link to The Java Tutorial on Networking.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Oh come on, you expect us to help you when you would not even spend a few moments reading the Community Rules.

Please use code tags, its as easy as putting
[code=jsp] and [/code] around your code. It preserves any indentation (which you have hopefully done), syntax highlighting and most important of all makes it easy for us to copy you post and try working with it at our end.

<EDIT>
Also gives us details on what errors you are getting, or what is being output in your webserver's logs etc.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The problem I think is being caused by :-

private static Connection con = null;

Because of that only one instance of your Database connection is maintained. But I think that is what you intend to do.
However let us take a look at the effects of this because you see in multithreading you have to think parallel and not sequential.

Now look at the "finally" block in your run() method.

finally{//make sure connection is closed
            try{
                mysqlconnector.disconnectdb();
            }catch(Exception e){}
        }

It calls the disconnectdb() method, which I feel is fine, because it should properly dispose of the database connection it acquired. However let us look at the disconnectdb() method :-

public void disconnectdb(){
  try {
    System.out.println("Closing connection...");
    con.close();
    System.out.println("Done");
  } catch (SQLException ex) { 
    Logger.getLogger(MySQLConnector.class.getName())
        .log(Level.SEVERE, null, ex);
  }
}

It just directly closes the database connection irrespective of whether it might be used in another different instance of "Client", So when your second object tried to access the database it finds that the connection has been closed (either while querying the database or while fetching the results from the ResultSet depending on the timing of completion of first thread).

Also remember that the same database connection cannot be used simultaneously by two threads for querying at the same time, you will need to close the resultset of the first thread and only then you can use the same connection for the second query, else you will get a "Connection Already in Use" …

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I'm confused by what you mean.

Well **I guess** he is requesting for some "sage" feature wherein if a thread is marked as a "Sage", any one posting in that thread (no matter how old it is) would not cause it to be bumped to top of the thread list.

This sounds like a good idea to counter people posting in old threads and disrupting current discussions.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Now referring to your import statements (Although jasimp has already given you the solution for finding the classes you made with "importing" them).
You import the classes and not the .java files, (unlike including the header files in C or C++).

A simple example is show below, here I am including the Hashtable class present in the java.util package. Also observe the second import statement where using the wildcard "*", I am including all the packages present in the java.awt package.

import java.util.Hashtable;
import java.awt.*;
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Your Brain Usage Profile:

Auditory : 46%
Visual : 53%
Left : 47%
Right : 52%


Description: Ditto as A.D.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Eclipse is an IDE which should be used only by programmers who have achieved at least a little proficiency in the language.
If you are just beginning out (which seems to be the case) I recommend the IDE JCreator Lite Edition.

so i believe it is an applet.

For an Applet your class will either extend the Applet class or the JApplet class, If its an application you will have at least one class with a main method.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

And what are you working on right now, an Applet or a normal GUI Application, I may not be able to help you but the information at least helps others know what you actually are trying to achieve.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Actually i dont understand why people dont want to show their faces in the forum?
we can take Dani as an example, she is the most preminent one and she does not need to hide her face.

If I am not wrong the cscgal profile does have her picture in it.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The problem you see is here :-

name = infile.nextLine();
  score = infile.nextDouble();

infile.nextLine() would read the entire line of text in your file, So on your first iteration in the while, your "name" variable would contain "Smith 13 20 8 12 -1" and after that line the token position in your File would be as shown by "^" below.

Smith 13 20 8 12 -1
Burch 21 18 16 -1
^
John -1
Mike 5 -1

Now at this point when your token is currently pointing to "Burch", you call infile.nextDouble(); , So bang !!! an input mismatch, your program is expecting a double value but instead finds a "String" and hence the InputMismatchException.

You can solve this problem by using the next() method instead of the nextLine() method. You can read more about the Scanner class from its javadocs here.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

>might as well be the geek lounge where the rep points wouldn't affect me
Perhaps I should slap you with a Keep It Pleasant infraction. You're not invincible here either, slick. ;)

Damn !!! of all the people in daniweb I pick the only SuperMod for my gloating.

** Puts tail between the legs and runs away **

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Amazing. Visiting the Geeks' Lounge is like sitting in a room full of children.

Well we have to vent out our life's frustrations somewhere (or at someone) :P, might as well be the geek lounge where the rep points wouldn't affect me

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Naah !!! For a guy who plays tit for tat with Bad Reps his IQ is too low to understand that.

Now because of the ambiguity I just want to mention 'his' = "serkan sendur".

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

@blackcompe

Teach a person to fish, do not give him the fish, thats the purpose of this forum, You should have at least let the O.P. attempt to use and understand the TreeMap collection on his own, and then help him with his solution, instead you have just given him the complete code to his assignment, and all he has to do is cut paste it without any need for understanding a thing !!!

Also I recall jasimp discouraging you from this practice, so why do you persist with it.

jasimp commented: Thanks for remembering :) +9
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

with treemap i can sort the student names in alphabetical order thats why i used it but the problem now is how do i make the tree map to function? or used the tree for the output

I have already linked you to the Javdocs of the TreeMap class in my previous post and also linked to an example on how to use TreeMaps, what more do you wish for ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

From there, a hosts file exists in system32\drivers\etc directory <for windows OS>
where am to edit / put put any number of entries in it

AFAIK that is nowhere concerned to hosting web sites on your machine. That file is in fact looked up by Windows for trying to resolve an IP Address for a specific domain name (before querying the same with your DNS if not found in this file).

Your Apache Web Server can host multiple web sites (with each website content organized into different directories) as long as you have individual virtual hosts configured for each and for that you have to only edit the configuration file of Apache (the file httpd.conf if I am not wrong). You can read more here regarding the VirtualHost directive.

<EDIT>
In fact the link I have forwarded you, also addresses your problem of hosting multiple websites on a single IP address.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Stop calling him Rashakil fool, maybe he will stop the 'war of words' too!

Naah !!! For a guy who plays tit for tat with Bad Reps his IQ is too low to understand that.

Rashakil Fol commented: Sorry, I don't understand what you're saying. -2
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I need to select a file and highlight it without selection

This has gotten me confused, is the second part not contradicting the first ???

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Now dear how do you expect the output to be in a sorted order unless

  1. The contents in the file are themselves in a sorted order --OR--.
  2. You manually sort the contents.

But you have done neither.

Also you have declared the "TreeMap" object and also initialized it, but never used it. I assume you have a faint Idea that a TreeMap can be used to sort and store you objects, So I will recommend you first visit the javadocs of the TreeMap class here and then check out this example of using the TreeMap.

Also the next time please use code tags whenever you are pasting code inside your posts, its as simple as putting the [code=java] and [/code] around your code. It keeps the indentations intact and also provides syntax highlighting for you code thereby making it more readable, you can read more about them here.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Unfortunately I do not see what your are trying to achieve here or what is your objective after even creating this file. Would you mind explaining to us your actual objective.
What you have mentioned here appears to be a means to an end. If you tell us what that end may be we can suggest a better means.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Help me, please. Where I can download z3950 server, I read him here http://developer.k-int.com/projects.php?page=z3950s. Thanks

**sigh**, Is it so difficult to read and understand what is happening on this thread ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

630

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

at last ...what should i do?

Read my previous post.
And you can learn here on how to create GUIs in swing without any fancy tools here.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

1.what is javadoc and how it works?

2.what Strong typing means?

My Answer :- STFW

3.if we want to control the input ,it is better to use exeption handeling (try chatch),or a single is to control the worng input,
whitch one is faster?

Exception Handling should be used for only handling "exceptional" situations. What you have mentioned can be done by performing appropriate validations on Input

catch(ArithmaticExeption a){
}
catch(IndexOutOfBoundsExeption a){
}

Yes its perfectly fine to have both variables named "a", because "a" is visible only inside the corresponding catch blocks and not outside of them. It wouldn't have killed you to just compile a program with the above situation, if it was incorrect at most you would have received a compile error.

serkan sendur commented: reputation is nothing -1
verruckt24 commented: What happen serkan sendur ? Giving bad rep to an o/w good post is basically misusing the power of it. I had to do this to counter off the effect. +3
Comatose commented: reputation is something +12
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

My Friend use Swing Components to make a desktop application with JAVA.

use NetBeans 6.0 to easiy create Database application and Desktop Application

you can get referance of it from www.netbeans.org site

Agreed Swing should be used to make a GUI (Graphical User Interface) in Java, but if you are just starting out with Java never use an IDE (like NetBeans) which automates all your tasks of GUI building. Instead use a minimalistic IDE like JCreator Lite or BlueJ wherein you have to do the component organization yourself and in case you get stuck refer to the javadocs, this way you will learn a lot more about Java.
And once you have achieved mastery over these basics you can go on and use IDEs like Eclipse, NetBeans, IntelliJ, JBuilder, etc and choose which one suits you best.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Here is a tutorial on how to work with Arrays in Java and here you will find a tutorial on how to take input from the Console.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

using Java Web Start technology (this could be on the internet or a local intranet) and works with an FTP server (apache commons has a good FTP library free for use)

I fail to see the context where the O.P. would want to use Java Web Start or FTP(File Transfer Protocol) ???

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well it seems that your application will need to be Network Aware, so you will need to work with Sockets or RMI . Then there are also advances concepts like Web Services and EJBs, but I believe they would be an overkill in your case.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

622

stephen84s 550 Nearly a Posting Virtuoso Featured Poster
java.lang.NullPointerException
org.apache.jsp.jsp.validate_jsp._jspService(org.apache.jsp.jsp.validate_jsp:118)

Quite clearly this is a problem inside your JSP code in the page "validate.jsp". You are most probably calling some method on an object reference initialized to "null" as below :-

String a = null;
int b = a.length();

The above code snippet would throw a NullPointerException when it is run on the second line. In order to trace the cause of the error. Go inside your Tomcat installation and open the corresponding servlet generated for your JSP page.
It should be most probably in the folder "$TOMCAT_HOME/work/org/apache/jsp/jsp/" and should be named "validate_jsp.java". Check what is happening on line number 118. If this JSP was written by you, you will be able to backtrack and locate the corresponding line in your JSP page and trace the root cause of the Error.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

622

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

If you want to do it in Java you could look at the JMonkey engine mentioned in the Starting Java sticky.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

622

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

618

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Guess what I found a direct API which does this conversion, although I do not know how it works :-
http://www.artofsolving.com/opensource/jodconverter

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

SavitchIn is a file that was given to me by my professor and this Savitch.readLine displays a line of character when the user inputs something.

According to me from what I see you want it to read a line of user input from the console into your String object (str1).
And reading from a console is quite easy using either the java.util.Scanner[ 1 , 2 ] class or the BufferedReader method.

Using the BufferedReader is as simple as :-

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

// Reads a line from the console
String input = reader.readLine();

There is also a third method (from Java 6 onwards) using the Console class .