stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Off topic but I have to ask:-

My wife's health is such that she would like to remove the presence of WiFi signals in the house if possible. This isn't as ludicrous as it sounds

You do realise that WHO (and countless other bodies) have found no link between WiFi signals and bad effects on health, unless the wifi switch you are using is not compliant with the local standards.
(https://www.arpansa.gov.au/understanding-radiation/radiation-sources/more-radiation-sources/wi-fi)

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well moved from C++ to Java (In college) and found the transition easier, then I had to temporarily move to C++ from a project and initially it was hell.
So if you already have worked on C++ and have put in some amount of effort in Java, I would suggest sticking to Core Java.

ALso I do not understand why you feel Python or PHP would be any easier to learn than Java, if you try to cover the same concepts in those languages, I think it should take a similar amount of effort.

Another thing I feel is you might be looking at this the wrong way. You should be focussing on your Data Structures and design skills (Object Oriented Analysis and Design), you might learn and become familiar with Collections API, etc but in the end we programmers are just problem solvers, good interviewers usually try to see your approach on analysing a problem and designing solutions for it.
Finding out whether to use a HashMap or a TreeMap or TreeSet or HashSet for a given situation in your data structures is easy (either google or just read the javadocs).
It is the how you think about the problem which is imp not just for interview, it will help you even on the job.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

h . x

I think you (or they) have forgotten to mention the Current Working Directory is 'test'.
So in that case 'javac' would not be able to find B.java in test and give you an error.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

First of, do you have to implement your own list? There a many list implementations in java.

This looks a lot a like a Home Work Assignement, so I wouldn't recommend using any of the inbuilt implementations in Java (unless you would want to risk getting a lower grade).

Another question, do you want to get a reversed list or just print the elements in reverse order, the latter is quite simple, in fact you already have the algo:-

if the element in a node is not equal to null, then we don't print anything till the next element become a null. When the next element equal to null, then we start to print the item.

Just Rephrasing it :-

PrintReverse(Node node)
  If node.next != null
    PrintReverse(node.next)
  Else 
    Print node.data
  End If

You can implement this algo as you see fit for your situation.

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

My JDBC knowledge maybe a little rusty here,but last time I checked 'executeQuery()' throws an exception if a ResultSet was not generated by your query and an SQL 'Update' does not generate a ResultSet. Suggest you use the executeUpdate() method instead.

Also another thing, when constructing a query the way you are:-

ResultSet res = stmt.executeQuery("UPDATE VIDEOS SET VIDEONAME = '" + v + "' , DIRECTOR = '" + s + "' , RATING = ' " + r + "' , PLAYCOUNT = ' " + p + " ' WHERE VIDEOID = '"+ f + "'");

It is always best to use a paremeterized PreparedStatement. That way if your variables 'v,s,r,p and f' contain apostrophes ('), you will not run into SQLException caused due to invalid SQL syntax.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Check the src.zip in your JDK installation, maybe you will find what you need

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

Doesn't your MySQL Workbench request for a User / Password when connecting to a database ? You can use the same credentials in your Java program as well.

BTW hopefully you are just playing with your own system here, as it is not recommended to use the 'root' account for normal day to day activities.

In case you have forgotten your root password but have access to the machine on which your mysql is installed, the following should help:-
http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

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

Hey if10066 can you please clarify what do you mean by deployed ? Do you mean just package them in a simple jar file or is this a web application which you are packaging in a WAR and deploying to some web server ???

If you are bundeling the mdb and rhe image files in you Jar, I do not correctly recollect, but there is a special way of accessing resources inside a JAR file. If you search the forum I am sure the question (accessing non-java resources in jar file) must have been answered before.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

There is already a Sticky Thread called Starting Java (http://www.daniweb.com/software-development/java/threads/99132) in the Java forum.

Please take sometime to at least look at some previous threads before posting your query.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

getSalesTotal() and getSalesCount() have been declared as double so they must return some value.
Declare them void if you do not wish to return any value from these methods

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

how would i do that print??

Um you really shouldnt be asking that ....

Put this line in your constructor.

System.out.println(x + " " + y + " " + ...);

And just to be sure, have you re-compiled your code after making the changes JC suggested in this first post ?

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

I have done it both ways ....

In that case you should try to understand what you are doing... currently you are erasing the values in the arguments you passed to your method waypoint() by the values already present in the member variables by default (in this case 0).

After the corrections JC pointed out, print out the values being read from the file returned by wps.nextInt(), maybe the problem is in the waypoints.txt file ??

--> Too late .. guess should refresh my page more often :P

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
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Although this thread is solved, just a piece of info, if you are looking for GUI generators in Java, you could look at the following IDEs:-
Eclipse: The Window Builder plugin for Eclipse is my favourite.
Netbeans IDE has a good GUI generator.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

No information about what is wrong, no information on how you expect it to work, no problem description, no code tags, Well I guess someone will have to use a crystal ball to help you out here.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

For "make your first guess" to go away, in your actionPerformed() method for the gField, set the text of the enterLabel to "".

Second question why do you "feel" you have a limited number of guesses, programs work on logic not feelings :P

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

What is it that exactly 'not works' ?
If its a compilation issue check your line 56, '$' should be ');'

Other than that you have to tell us how you want the program to behave to point you to a solution.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

@varia
Honestly I cant really make sense of your requirement, could you explain it with an example ?

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

Tomcat is a web server (at max an application server with the correct plug-ins), so you can run only web applications(JSPs, servlets, HTML pages) or enterprise apps ( EJBs, Web Services etc).

AFAIK you cannot run exes in Tomcat.

Now JNLP is a different situation, it involves deploying you Java web start application, I have linked you to its tutorial, if you need more info.

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

Heres an old thread addressing a similar issue:-
http://www.daniweb.com/forums/thread21906.html

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well those are the steps that happen when a class is loaded for the first time(and your class has to be loaded before any static methods on it can be executed in this case the main) in your JVM,

  • First your static variables are initialised
  • Next your static blocks are executed

You could check this by moving the main method to another class and by trying to create an object of this class or by calling the math() method directly.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

From my first glance, I do not think package 'simple' and 'Simple' are the same in Java, remember identifiers are case sensitive in Java.
Thats looks to be the reason behind the classes not able to access each others members. Not to mention your MyDialog class has default access due to which it will not be visible to any class outside the 'Simple' package even if you try to explicitly import it.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Why do you want us to explain your own code ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Use code tags in your original message, the way the post is displayed its too painful to read.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The problem with the so called duplicate parameter is cause you are reusing the identifier 'e', for every exception you are trying to catch even though you have already used up that identifier here:-

FileNotFoundException e

Try using some other identifiers like 'ex' or 'ioe' etc, the Java rules for identifiers are flexible enough to for you to not have to stick to just one name over and over again.

Regarding the other errors:-

e;//Syntax error, insert "AssignmentOperator Expression" to complete Expression//
Exception exception;
        exception; //Syntax error, insert "AssignmentOperator Expression" to complete Expression//

The above snippets from you code do not do anything so deleting them will not have any effect on your program, but just out of curiosity what are you trying to attempt there ???

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

can anyone provide with java code for performing text similarity

No, not even a hint until you show us what you tried.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Observe carefully the chunk of code which tries to read the date :-

// Get date from user
		System.out.print("Please enter the date. ");
		date = keyboard.nextInt();

Now the program here is expecting an integer value, However you are feeding it 11/11/2010 Now that doesn't look like an integer to me from any perspective, Hence the 'java.util.InputMismatchException', when you enter the date, try using just an integer value like '10', it will go on and ask the payee name.
Take a look at the javadocs of the Scanner class, it should help you get an insight how its methods behave.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

When I pasted your code on eclipse, it said that if your using abstract, you cant use protected. Only public, final and abstract are permitted.

Thats what happens when you rely too much on your IDE to tell you the errors. ;)

@ O.P.
Read up on your Access Modifiers, a class can have only default access or public, if you read up on private and protected you will figure out why they dont make sense for a class.

@Akill10
Your solution to Error#2 is incorrect, note the method is declared as abstract so it cannot have a body. I too agree with NormR1 on that one, the second error seems more like a side effect of the first one.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Hopefully this or this should help, but they store image as OLE, so I don't know how much it answers your question.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well just a guess, is your 'UserDataFile.txt' completely clean before you write your ArrayList to it ?
Also try closing your ObjectOutputStream once you are done writing the ArrayList, but since you mention that the object writing code works correctly, that shouldn't be the problem.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

What the hell do you mean by 'name' ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Implement a Priority Queue, the Jobs can be the elements in the Queue and the priority of your Job element could be determined by some property example 'jobLength', So that whenever you try to remove an element from the queue, the element with the least value of 'jobLength' would be returned.