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.
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.
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).
<Ignore>
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.
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.
@ejosiah
Both those options were already covered in my post.
No, We are not hiring now anyways. ;)
Not to mention the hell of a first impression he has already made.
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.
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.
Strange even I had the Notion of HDDs being faster than SSDs but not only the Wiki even googling says otherwise.
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 …
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 ?
not stalking at this stage, a little bit curiousity..
You mean preparing to stalk. ;)
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.
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" …
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.
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.*;
Your Brain Usage Profile:
Auditory : 46%
Visual : 53%
Left : 47%
Right : 52%
Description: Ditto as A.D.
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.
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.
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.
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.
>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 **
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
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".
@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.
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 ?
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.
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.
I need to select a file and highlight it without selection
This has gotten me confused, is the second part not contradicting the first ???
Now dear how do you expect the output to be in a sorted order unless
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.
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.
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 ?
630
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.
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.
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.
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) ???
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.
622
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.
622
If you want to do it in Java you could look at the JMonkey engine mentioned in the Starting Java sticky.
622
618
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
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 .