stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The Program is looking for a class called: "javaapplication7.TelephoneDirectory"
Your class (atleast the code you pasted) is in the default package, you need to declare your classes to be in the "javaapplication7" package by adding the following statement at the top of your Java file (Even before the import statements)

package javaapplication7;

Also note your classfile will need to be in a folder called 'javaapplication7'.
If you are doing this via an IDE, then I suppose it will handle these teenie weenie details.

stultuske commented: missed that one, should 've read the code more carefully :) +15
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

It compiled and ran without errors beforehand anyways.

I literally just removed generic types and added a few // UNUSED lines

Considering the OP never gave stack traces, I don't know how else to help.

How about wait for him to respond with relevant info,
Now as you see he has again skipped the error message.


@raym
Error messages please ??

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

So .... what functionality you want to add, what have you tried to add that functionality, if not I would suggest you jot down somewhere clearly what you want this calculator ... and then work on an implementation. If you get stuck there we are here to help ..

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I copied and pasted the code into Eclipse and got rid of warnings, ran it and tested no issues.

Here is the code I used.

Link

(Used pastebin to reduce spam)

Hmmm, giving fish instead of teaching someone to fish ....

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

For Line 4, I am guessing now its a warning, since the O.P. hasn't provided type arguments for Comparable.
'Directory' has a default access level, so it's name doesn't need to match the name of the file, it is only required for classes with 'public' access level.

@raym.mart
You may want to look into this tutorial on Object ordering: http://docs.oracle.com/javase/tutorial/collections/interfaces/order.html

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Just a guess for the error on Line 50, is your Java file correctly named as : TelephoneDirectory.java (even the case, don't care if you are on windows or linux), the name of the file, should match the name of the public class it contains

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Dude, the error messages .... my crystal ball isn't lighting up !!! :P

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

First let us know what you are trying to do, next tell us the errors, or the incorrect behaviour in your code, do you seriously expect people to sift through 200 lines of code searching for errors ??

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

You already have that part figured out here, in your chunk of code:-

System.out.println("Now please enter the location of this text file!\nAn example would be: C:\\Users\\Your Name\\Desktop\\FolderWithTextFile\textfile.txt");
  Scanner userInput = new Scanner(System.in);
  String nameWithLocation = userInput.nextLine();

'nameWithLocation' already has the path to the file the user specified, you just need that to construct your FileReader object as mentioned in the given tutorial. Just go on and give it a try ...

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Checkout the Scanner tutorial here: http://docs.oracle.com/javase/tutorial/essential/io/scanning.html , the example mentioned is doing something similar.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Seriously just wondering, Shouldn't C:\'Users\'gourav\'Documents\'NetBeansProjects\'WebApplication2\'web\'league1.txt actually be C:\\Users\\gourav\\Documents\\NetBeansProjects\\WebApplication2\\web\\league1.txt

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Hi everyone,

I am doing a Java course at uni at the moment and it kinda doesn't make you become a real programmer with the confidence that a programmer should have. I really want to program in Java and any language(not python though because it is not a user-friendly programming language... its syntax is horrible!!! sorry python programmers) The problem I'm facing is that I don't know how to think like a real programmer.. If anyone can help, that'd be GREAT and be a life saver for a young man like me..

Looking forward to fellows' thoughts on this...

You seem to be looking for a fast track way to become a good programmer and no just positive thinking isn't enough, and you are correct your course will not perform some enchantments on you that viola at the end of it you will become a good programmer.

A programmer is just a problem solver, First hes given a problem, next he has to solve it, When he successfully solves the problem, he backtracks on the steps he used to solve the problem (the Algorithm) and then converts the steps into code.

And how do you get good at solving problems ... by solving problems (start small like printing the pascal triangle or some patterns and slowly moving up).

Ezzaral commented: Agreed. +15
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

And How do you expect us to help, we do not know what is you are trying to do, what problem you have run into.
You have just told us the name of an encryption algo ???

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well since I had a lot of time on my hands :P , I studied every line of code, the problem looks to be on line 109 you have reinitialized the variable 'jlbMovie', while on line 119 you are setting the bounds for the text field 'jtfMovie' which has never been initialized, so is null.

I am guessing the O.P. intended to initialize 'jtfMovie' on line 109.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

You can use the JAVA_OPTS environment variable.
It is similar to enabling gc logging for a normal JVM just pass the same options in JAVA_OPTS and restart tomcat.

example on Linux:-

export JAVA_OPTS=-verbose:gc -Xloggc:logfile

the above should work, but remember the 'logfile' will be cleared at every JVM restart.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Did you create a runnable jar ? or just a jar ?

For a runnable jar you can give the runtime configuration, which will include the main class, something your manifest file seems to be missing.

From the console try running your jar file as:-

java -jar jarfilename.jar <fully qualified name of Main Class>

If it runs via the above command, then the only issue is the main class attribute in your manifest file, else extract your jar file using any zip extraction utilities and check what you are missing.

If you are creating jar files for the first time then knowing the jar file format helps understand such problems, you can check the following link: http://download.oracle.com/javase/tutorial/deployment/jar/index.html

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

that how can we implement BFS algo. in Java.

Translate the Algo into Java code and you will have its implementation.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

hi.....
i need to do a project on bulk sms.
i request you to send
java application for sending bulk sms from pc to mobile
by
kareena

I think the idea of it being your project is that you should make the application, not rip someone's hard work for your marks (if its an academic project) or money (if you are doing it commercially).

You have in this thread what you need to start making your own application, if you run into any road blocks you can definitely count on the people in this community to help out, but only if you put in the effort.

peter_budo commented: Obviously some students do not get it that in deed has to be their work not stolen material +15
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Ok ... If the JSP file is not too long could you post it ?
Cause I can't spot any reason for that error, from what has been posted.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster
<%
----
---
-----

UrlGen urlg = new UrlGen(request.getQueryString(), "UTF-8");
String url = "Contacts.jsp"+"?"+urlg;

%>
<a href="<%=url%>"><img src="images/hide.gif" border=0 align="middle">
</a>
<%
--
--
%>

If that is the exact reproduction of your JSP file, then you are bound to get errors and tons of them cause, "---" is not valid Java syntax.
Remove all those hyphens ("-") and retry.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

A Quote from the announcement section:-

Also, to keep DaniWeb a student-friendly place to learn, don't expect quick solutions to your homework. We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well.

So ... where is your effort ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

but somebody tell me why i was getting this error?

You did not post the contents of your web.xml file, so unless and until someone has a crystal ball here which can look into your past, it cannot be answered. All that can be guessed is, you did not add your servlet correctly the first time around to your web.xml

@Override - is an annotation, a marker, If a method marked with @Override fails to correctly override a method in one of its superclasses, the compiler generates an error.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Post the contents of your web.xml file, since the problem appears to be there.
Also I hope you have placed your class file (of the Servlet class), at the correct location (WEB-INF/classes or WEB-INF/lib[for jars]).

Another thing is remember to close your PrintWriter once you are done using it, like in processRequest().

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Yep, thats it.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

It probably doesn't because it extends AbstractMap which already defines equals to perform content based comparison, not reference based.

AbstractMap defines the equals method based on which Maps, extending it can be compared. It seems to me that you are confusing it with the equals() method of the 'keys' which are stored inside the Map.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

how do i go about checking for the last character of the line if I just want to discard the line that has H at the end of it and wants the other lines that contains C, O and N?

Thats the reason why I have added link to the regex tutorial, read it and construct your pattern according to what you wish to check, I already have given an example pattern which checks the Starting and ending character of a String.

Read your input file one line at a time into a String against which you check for the occurrence of your pattern (using the matches() method). If the match is successful concatenate this String, with a third string which contains the data you want to write to the new file.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Using regular expressions you can check for patterns in your input.
Example:

String a = new String("1234");
if (a.matches("[0-9]+")) {
  System.out.println("String is a number");
}

In the above chunk of code the regex "[0-9]+" tests if the Given String is a number, you can construct a regular expression for your pattern along similar lines.
Example If I want to test for a String starting with "A" and ending with "N" the regex (regular expression) would be "[A][.]*[N]"

Use the regular expression to test if the input matches your pattern, if it does, then concatenate the data you wish to write to the file in another String variable (ex: dataToWrite).
Once you are done processing the input use File IO to dump the data in your dataToWrite variable into a File.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Use Regular Expressions for Pattern Matching.
Tutorial for Regular Expressions:- http://java.sun.com/docs/books/tutorial/essential/regex/

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

-Xbootclasspath/p:'D:\Document's\Downloads\wiiuse\SampleAppWiiuseJ\${endorsed.classpath}'

Checkout line 199 in your build-impl.xml, and see if the extra quote in Document's is valid, if you have no such folder, then delete the quote.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The API says:-

BlockingQueue implementations are thread-safe. All queuing methods achieve their effects atomically using internal locks or other forms of concurrency control. However, the bulk Collection operations addAll, containsAll, retainAll and removeAll are not necessarily performed atomically unless specified otherwise in an implementation

It says specifically "bulk Collection operations .... are not thread safe unless specified otherwise in an implementation", and if you think about it "drainTo()" does fall in the said category.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The data download for your newfile.csv, doesn't fail, it is downloaded, try opening that file via notepad or some other text editor and you should get have all the data in it (even if the file has more than 65535 rows), the problem is with 'MS Excel', it cannot handle more than 65k rows.
If you have to use 'MS Excel' to view or manipulate your data then in that case take a look at the Apache POI and write your data into an XLS format (Currently you are using the good ol' comma-separated-version CSV), and use multiple sheets to store your data in case it exceeds 65535 rows.

Note:-
XLS is the name of the extension used when you save the file in Excel '97(-2007) format. The formal format name my guess is BIFF8

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Sharath,
When you specify "codebase = /WebContent/WEB-INF/" the browser will serach for the Class file of your Applet in the "/WebContent/WEB-INF/" in the directory in which it is running on the client machine where your servlet output is being displayed, it does not look for the class file on the server where your servlet is deployed.

For the browser to look for your applet class on the server, you need a URL of the type "http://...../" to your "codebase".

Here is what I am trying to say.

Also the class file of your applet will need to be moved out from the WEB-INF directory and into another folder from where the browser can access it via the "http://...." URL pattern

Also this should also prove somewhat useful.

Also please use code tags from the next time whenever you post any code.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

new keyword in java is the way of creating an object class - hope this helps

Considering the fact that the O.P. asked the question in Feb 2009, I am guessing he already got the answer or gave up and chose a different career :P

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I thought the Hash's comparison between two object should be by their equals method,

The comparison is within the hash bucket, if two objects return the same hashcode then only the equality check by equals() takes place as mentioned below on http://www.ibm.com/developerworks/java/library/j-jtp05273.html

The interface contract for Object requires that if two objects are equal according to equals(), then they must have the same hashCode() value. Why does our root object class need hashCode(), when its discriminating ability is entirely subsumed by that of equals()? The hashCode() method exists purely for efficiency. The Java platform architects anticipated the importance of hash-based collection classes -- such as Hashtable, HashMap, and HashSet -- in typical Java applications, and comparing against many objects with equals() can be computationally expensive. Having every Java object support hashCode() allows for efficient storage and retrieval using hash-based collections.

So in the end my advice is check if the hashcode returned by the two objects is the same.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The comparison operator in Java is "==" not "=".
Change that on line numbers 7 and 9 and check whether it works.

"=" is the assignment operator, so you are actually setting the value to your array element there.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

From your post I am a bit lost on what you wish to do, but since the thread topic states you need help on arrays, here is a link to the Java Tutorial on Arrays

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

That is because the charAt() method of the String class returns a "char" and you are assigning it to a String type.
Use the Charater.toString(char), to convert you 'char' to a String type.
Or alternatively you could make your "sample" variable from a String array to a 'char' array.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Actually I have no clue of how to fix line 4 to 17 but I have fixed the Sum method and it looks something like;

Well I can see how this can be fixed, but I need to know your motive in writing lines 4 to 17, are they for testing your code like in a main as VernonDozier says??
Also why does your sum() method need to return an "Integer" object, would an "int" not be just fine ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

For the past 6 years, I've been doing development work with C# and loved Visual Studio (probably a bad word around here). Intellisense is good, smooth debugging is good. With jsp, there was talk of tools working on better debugging facilities last I developed on jsp. Did any of those concepts come to the surface? I'm ok with free or pay tool, I just want quality...

Peter already hit you with the most popular suggestions for both sides:-

Free Stuff:-
Eclipse, NetBeans

Commercial:-
IntelliJ IDEA, MyEclipse, Dreamweaver*

*Dont know if I can call Dreamweaver an IDE but it does provide some good bundle of stuff for Web designing.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Now I haven't gone through your code, but if you are looking for a data structure which can hold a list and gives you the facility to delete any element at random I suggest you take a look at the followinf:-
ArrayList
HashSet
HashMap
TreeSet
TreeMap

However if you are hell bent on using just an "array", you will have to write you own functions to move data around in the array, overwriting any location which is deleted by moving the values from the behind indexes up one place etc.

By the way, I don't care how it looks, I am not being graded on appearance but on functionality.

Just a piece of advice do not concentrate on the grades so much that you forget the main motive of this subject being given to or taken up by you.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

@ryy705
Now when I run javac -help I get the following message:-

stephen@stephen-desktop:~$ javac -help
Eclipse Java Compiler 0.894_R34x, 3.4.2 release
Copyright IBM Corp 2000, 2008. All rights reserved.

Usage: <options> <source files | directories>

Although I use the Eclipse Java compiler, but then too the usage should be the same even with the Sun JDK.
Now if you notice the above usage information properly, you need to specify your options before you specify your source files to compile, So you need to specify your CLASS path information (using the -cp option) before you specify the source files to compile, So instead of

javac JakartaFtpWrapper.java JakartaWrapperTest.java -cp commons-net-ftp-2.0.jar

try running this :-

javac -cp commons-net-ftp-2.0.jar JakartaFtpWrapper.java JakartaWrapperTest.java

And check if your sources compile.
Also while running run as :-

java -cp commons-net-ftp-2.0.jar:. <fully-qualified-name-of-main-class>

If on windows replace the ":" with ";" and do not forget the "." after it, it tells the JVM to search for the Main class in your current working directory. Hope it helps

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Hi James, you have to use the noparse tags around the code tags like this:-

[noparse] [code=xyz]

[/code]


[/noparse]

In fact check this post by John A for an even better option.

You can check the entire vB Code list here

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I agree with VernonDozier, your code compiled and ran OK,
You should not be getting this problem unless and until you are using a Java compiler prior to release 1.2 (i.e a pre Java2 compiler cause nextInt(int) was added to the java.util.Random class in JDK 1.2)

freelancelote commented: thanks a lot +1
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

No problems, with the line numbers, I appreciate the fact that even though new you even care to use code tags.
The line numbers will come up if you wrap you code inside [code=java] and [/code] tags.

Anyways the problem is as follows:-
the NullPointerException was thrown on the line:-

GradientPaint bounds = new GradientPaint(x, y ,c.getColor(), 0, 20, Color.white, true);

Because c.getColor() returned "null".
If you look at the previous line you have initialized "c" with a new object of class MouseOverExample as shown below.

MouseOverExample c = new MouseOverExample();

But since you have used the default constructor, none of its internal properties are initialized, they are just set to null. As a result of which c.getColor() returns null, and hence the reason for the NullPointerException thrown from the GradientPaint constructor.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Can you point out which is the line specified here :-

at MyPackage.MouseOverExample$Glyph.<init>(MouseOverExample.java:109)
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

@lloydsbackyard

I dont know what you are talking about. When I ran your code, it worked perfectly:-

stephen@xxx:~/Development/java> javac bonus.java
stephen@xxx:~/Development/java> java bonus
Enter Employee's Monthly Salary:
6000
The bonus is 6000
stephen@xxx:~/Development/java>

Also just to inform you the code that you pasted contains an extra "}".
And from the next time if put code in your post, please use code tags, for java code it is as simple as using:-
[code=java] and [/code] before and after your code respectively.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

My code compiles but does not print the contents of the ExtendDVD class. I have the three classes saved as seperate files.

Well just a quick Search of your code revealed that you have never created an Object of ExtendDVD so I guess its logical that nothing from it would be printed.

VernonDozier commented: Beat me to it! +15
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Rather than making your own why dont you just try some of the freely available Database Connection Pooling libraries.
Look here for a list of them, For my apps I normally used the DBPool library.
Alternatively if you are using Tomcat you can check this article

So if you use a standard pool of database connections, whenever you wish to query the database, just checkout a connection from the pool, fire your query, process the resultset if any and return the connection back to the pool.
So you neither will have the problem of continuously opening and closing connections nor the problem for one user occupying one DB connection for his entire session.
Also you can read the following references to know more about the importance of Connection pooling : 1,2

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

i just left the answer blank. that is why i was really surprised to see a c++ geek who is blonde and cute( i am not allowed to give her name, you know her anyways).

Dude, not again !!!!

please if you read my threads, dont read them with attitude or prejudgement. the escense of why i write here is sharing, decreasing the feeling of loneliness in me. that is it, nothing more nothing less..

Now although you say the above, you did say earlier :-

The problem is in this area i dont think there are enough depth thinkers or educated people.

So even though you wish to escape judgment from us on your character based on your thoughts, you go on and do the same to all people (the girls I assume) in your area.

And the problem is not out there, its in you, before hunting for a girlfriend why dont you make a few girl-friends first.
Also what kind of girls do you expect to find at strip joints ??? Even though I have never been near one, I can definitely bet they wont we those smart programmer types you are looking for.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

There is no comnspiracy, the Dude deserved it, as did everyone else who gets banned. There is no conspiracy when the application of the law is universal.

We told him 3 times about piracy and about 2 spam, and each time he ignored the warnings, so he got a ban.

Chill JB, I wrote "conspiracy theory" with just a light heart, no need for any justifications here :D .