This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

John Drulo

+ Follow
since Dec 14, 2014
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by John Drulo

I wanted to build an mp3 player as a Java project. One crucial part of the project involves being able to play an mp3 fie. I am not able to find the right api(if one exists) and am not able to find a suitable answer when searching on the web.

Can someone give me a simple code snippet illustrating the playing of mp3 file using Java program.
Also, I am using Eclipse IDE and please tell me how to import files if any importing of files is required.
5 years ago

Ulf Dittmer wrote:If you haven't learned servlets/JSPs yet, how do you know that PHP is much better?

Because whenever I hear server side language, I hear PHP. I never heard about JSP. PHP's popularity in the programming world, may have come from its superiority
5 years ago
Given that there are much better and popular server side languages like PHP.

I mean is there any point investing my time learning Servlets or JSP when PHP can do the job.

Are there situations where you Servlets or JSP have an advantage or can do something that PHP cannot?
5 years ago
Hi I am new to Servlets and came across it in Head First Java 2nd Edition. I wrote the servlet code. I don't know how to run it. Do I need to set up a server? How to do that?
5 years ago

Tony Docherty wrote:I vaguely remember skeletons have not been needed since Java 1.2 (or that could be Java 1.4 - either way quite a long time). From Java 5 onwards running RMIC is no longer needed, see the RMI tutorial

Hi Tony,

In the book Head First Java 2nd Edition that I am following , there is ample reference to Java 5.0(Tiger). So the authors of the book, wrote the book after Java 5.0 was released. And they specifically mention that both the stub and skeleton code will be generated on running rmic on the remote implementation. Are they wrong in saying so?
5 years ago
Interface code:

Implementation class code:

This only generated the stub code when was run in the command prompt(Windows XP).

According to the HeadFirstJava text book, the skeleton code must also be generated.Why is it not generated?
5 years ago
Consider the following interface:

Which is implemented by the following class:

Although meth() is a method that throws an exception, the caller of the method meth() is not having to handle or declare the exception and yet the program runs successfully. Why is this the case? Does it not violate the rule that whenever you call a method that throws an exception, you need to catch the exception or declare that you throw the exception yourself?
5 years ago

Kathy Sierra wrote:Howdy -
Java Web Start (JWS) is kind of a cross between applets and regular stand-alone Java GUI clients. It's a way to have an application *delivered* over the Web, but unlike an applet, the Web Start-deployed application does not run under the control of a browser.
The end-user must have Java Web Start installed (all versions of Mac OSX come with it pre-installed, with other OS's the user has to install it much in the way you install a browser plug-in).
JWS is a small Java program that lives on the client machine, and it's role in life is to manage downloading, updating, and executing your application.
Here's an overview of the main steps to JWS:
1) Make an executable JAR (which means you have a class in the JAR with a main() method, and you write a manifest that specifies which class in the JAR should have its main() invoked to start the app).
2) You must also make a .jnlp file (a really simple XML doc that tells JWS how to deal with your application).
3) Place your JAR and your .jnlp file on your web server, just like any other web application files (like plain old html files, etc.)
4) Add a new mime-type to your web server:
5) Create a web page with a link to your .jnlp file:

That's pretty much it. The client clicks to the link, the browser downloads the .jnlp file, and assuming that JWS is configured, the browser launches JWS as a "helper app" (similar to the way it runs, say, Acrobat Reader), and then JWS presents a little interface to the end user.
A couple of cool things about JWS are that the application, once downloaded, now LIVES on the client machine, which means the client can now run the app again without having to download it. In fact, the client doesn't even need to be online next time.
But better than that... JWS can manage incremental updating, so if you change just one class in your app, JWS can download and update just that one class, rather than having to download the whole JAR again.
I don't know how JWS is being used in the real world right now, but it sure is cool.

Hi Kathy,
I had a few doubts about Java Web Start which I posted here in the forum. Could you please have a look.

5 years ago

I am a beginner in Java who came across the chapter in Head First Java about making Web Start Apps. I understood the basic idea that it is a way to deploy your apps over the internet. It can be stored on your server. A link to your server can be provided on a web page. When user clicks a link on your web page, a .jnlp file is sent to him, which is opened by the client's browser using a Web Start Helper app. On opening the .jnlp file, the browser, requests the JAR file from the server and runs the main() method of the Main-Class. Information about the Main-Class that contains the main() method is provided in the .jnlp file. Once, downloaded to the clients system, it can be run like any standalone app can, with an exception that it has restricted access to the client machine's hard drive.

Am I wrong in the understanding that I have of Web Start apps above?

What I did not understand:

1) How to make .jnlp files?
2) What exactly are Web Start Helper apps? Can we make them easily? Are there standard Helper apps out there that we can download and install for free? What are a few examples/names of such Helper apps out there on the Web?
3)How do I know whether my browser already has a Web Start Helper app installed?
4)If I want to try/test my own Web Start app, on my own machine,using, do I need to have software such as XAMPP installed to make my machine behave like a server or are there other means?
5) Can some one please give me a link that gives a "head-first" like explanation about Web Start i.e any tutorial that is easy to understand / not arcane?
6) Are Web Start apps widely used? Is it sensible for me to invest time in learning it(I feel like it will take quite some effort and time for me to wrap my head around it, given that I have no Web Development background)? Or can I just leave it?
7) What is a mime-type?

Lastly, a humble suggestion to the Head First Java Team:
All the chapters are really well written, but this particular chapter does not provide enough content/explanation to enable the reader to make his own Web Start app after having read the chapter.
5 years ago
I was reading the chapter on deploying the code and came across this thing called class path. I googled it and found many resources , but found the resources to be arcane and difficult to understand.

Can somebody please give me a Head First version of:
1) What a class path is exactly?
2) Given that I am nearing the end of the Head First Book, how do I google and figure out such arcane stuff on my own, without having to pester you guys all the time. Like , how would you guys go about finding what a class path is if you hadn't a clue about it?

Yours Gratefully,
5 years ago
I saw the following excerpt in HeadFirstJava, 2nd Edition pg 500
"I've seen examples that don't use a separate
Runnable Implementation, but Instead Just make a
subclass of Thread and override the Thread's runO
method. That way,you call the Thread's no--arg
constructor when you make the new thread;
Thread t = new Thread(); 1/no Runnable"

Can someone please provide a simple code that demonstrates the same. I haven't fully understood what is said in the text above. I have a hunch that the last line is wrong and it should be
Thread t = new <Whatever class extends Thread class and over rides its run method>()

Am I correct or wrong
5 years ago
What is the advantage of using PrintWriter over BufferedWriter, when we are writing one String at a time?

Reference:pg 479 , Head First Java ,2nd Edition
5 years ago
The book states the following:
if someone writes a network service
and wants others to write clients for
it , they'll publish the lP address, port
number, and protocol for the service."

It has been previously stated in the text that in order to connect to an application on a server, the port number of the application and the IP address of the server suffices. Is the protocol used by the application necessary? In which cases are they necessary and in which cases can we make do without them? What is a protocol in the first place? How does it aid in connecting to the server application?
5 years ago

Tushar Goel wrote:I tested following condition:

1) Super class is not serialized but sub class is:
output : Super class variables showing default value instead of the value i set them and for sub class it showing same value i set.

2) Super class is serialized but sub class is not explicitly:
output : All variables showing same value i set.

3) Now i created 1 more subclass (1 <- 2 <- 3) , total have 3 class, 1 is not serialized, 2nd is and in 3rd i mentioned explicitly
output : variables used in 1st class showing default value instead of value i set and rest of variables defined in subclass 2 and its subclass 3 showing
the value i set.

So, I think we can draw the following conclusion from the experiment you carried out:

If a superclass implements Serializable, all its sub classes also implicitly implement Serializable and hence are Serializable, thereby adhering to the rules of inheritance in Object Oriented Design Paradigm. Also, the interface Serializable is no different from other interfaces, atleast with regards to inheritance in this context.

Am I right?
5 years ago
My question is if a class is non serializable, then how can its super class be serializable? Because they say that even the constructor of those classes will run. But such a situation will never arise right?
5 years ago