Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Applet in browser

 
Joseph Tagarelli
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all.I m a student of informatics degree,and i am studying java language.First of all,sorry for my bad english but im not english.My project is a client-server project where i send the client choices with an applet.Now,this applet works on my ide(Eclipse) but i need to run it in browser,but i dont know how to do this.I hope you can teach me how do this.
 
Les Morgan
Rancher
Posts: 711
17
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Enable Java in your browser.
Encapsulate the applet in an HTML file.
Double click on the HTML file and select open in browser or you can do a <file><open> with your browser.

Here is a link on a howto, it's kind of old, so you needn't go through the whole reboot process and dos mode.

 
Joseph Tagarelli
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Les Morgan wrote:Enable Java in your browser.
Encapsulate the applet in an HTML file.
Double click on the HTML file and select open in browser or you can do a <file><open> with your browser.

Here is a link on a howto, it's kind of old, so you needn't go through the whole reboot process and dos mode.



I created a .jar with .class files and a directory for images that applet load..but when i open it in browser i have a "NoClassDefFoundError"
 
Les Morgan
Rancher
Posts: 711
17
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You know it is a lot easier to help people that actually tell what it is that they need. Before anyone attempts to help you any further, please detail what you have done and the whole error message that is given. Also if your "applet" is not any more than 20 to 30 lines long, then please post it and please use code tags to do so.

Joseph Tagarelli wrote:I created a .jar with .class files and a directory for images that applet load..but when i open it in browser i have a "NoClassDefFoundError"
 
Joseph Tagarelli
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Les Morgan wrote:You know it is a lot easier to help people that actually tell what it is that they need. Before anyone attempts to help you any further, please detail what you have done and the whole error message that is given.

Joseph Tagarelli wrote:I created a .jar with .class files and a directory for images that applet load..but when i open it in browser i have a "NoClassDefFoundError"

I have a file called XMeansClient that is my applet.In the same directory i created a .html that contains:

My project contain 5 package,2 of these are "client" and "server".The client is my applet(that use two image) that send to server the data that need to run my project,using other package.So,i dont know if my jar file is correct,it contains all .class of client package and the two images.My applet and server run correctly in Eclipse ide,but i need to run the applet in browser.When i open my .html in browser i received "NoClassDefFoundError,XMeansClient(wrog name:client/XMeansClient)".If i click on detail there is this:
CacheEntry[file:/C:/Users/Jt1995/workspace/Xmeans/bin/client/xmeans.jar]: updateAvailable=false,lastModified=Fri Jun 03 19:03:56 CEST 2016,length=13890
 
Les Morgan
Rancher
Posts: 711
17
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joseph,

That is the post you should have led with. I am and always will be a "show me and let me see it, so I can tweek it" type of person. Without having the ability to putz with the code, I am past where I can help you any longer.

My only further suggestion is make a small applet, maybe 10 lines long and see if you can get it to work.

Remember in future posts: specifics will get you specific results, otherwise, you can only get recommendations, that will usually not pertain to your actual problem, and guesses.

Les
 
Tony Docherty
Bartender
Posts: 3054
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are missing a '>' from your applet tag or is that a typo in your post?

What package is the XMeansClient class in?
 
Joseph Tagarelli
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:You are missing a '>' from your applet tag or is that a typo in your post?

What package is the XMeansClient class in?

XMeansClient is in "client" package,i try with code="client.XMeansClient.class" but i received nullpointerexception..and in details there is CacheEntry[file:/C:/Users/Jt1995/workspace/Xmeans/bin/xmeans.jar]: updateAvailable=false,lastModified=Fri Jun 03 21:47:15 CEST 2016,length=51303
 
Paul Clapham
Sheriff
Posts: 21581
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joseph Tagarelli wrote:XMeansClient is in "client" package


And in your jar file, is XMeansClient in the "client" folder? The error message (which says "wrong name") suggests that it isn't.
 
Joseph Tagarelli
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:
Joseph Tagarelli wrote:XMeansClient is in "client" package


And in your jar file, is XMeansClient in the "client" folder? The error message (which says "wrong name") suggests that it isn't.

Yes,it is
 
Paul Clapham
Sheriff
Posts: 21581
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, frankly I would suggest you stop messing about with applets and just write a plain old Java application to do your client-server project. Using applets just gets you bogged down in configuration issues -- like this one, but there will be more. The only reason to use an applet, really, is that your instructors are requiring you to do that. And even if they are that's a questionable requirement, because nobody uses applets any more unless there's a really really good reason to fight through all of the setup required.
 
Joseph Tagarelli
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Well, frankly I would suggest you stop messing about with applets and just write a plain old Java application to do your client-server project. Using applets just gets you bogged down in configuration issues -- like this one, but there will be more. The only reason to use an applet, really, is that your instructors are requiring you to do that. And even if they are that's a questionable requirement, because nobody uses applets any more unless there's a really really good reason to fight through all of the setup required.

Yes..i must run it on browser.I dont know why it runs on eclipse but dont in browser
 
Tony Docherty
Bartender
Posts: 3054
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I may be wrong (It's a long time since I've done anything with applets because, as Paul has already said, they are a dead technology) but I think your "code=XMeansClient.class" should include the package name ie code=client.XMeansClient.class >
 
Joseph Tagarelli
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote: I may be wrong (It's a long time since I've done anything with applets because, as Paul has already said, they are a dead technology) but I think your "code=XMeansClient.class" should include the package name ie code=client.XMeansClient.class >

i did it..but it doesnt run..i dont know
 
Tim Holloway
Saloon Keeper
Posts: 18367
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The applet runs in Eclipse because it's using the stand-alone AppletRunner, which doesn't require all the configuration that an actual web page does, nor - and most importantly - does it require an actual webserver to serve the containing webpage and applet code from.

The #1 reason that "applets are dead" is because a series of very serious security holes were discovered in Java that could be exploited by malicious applets, thus tarnishing the reputation of not only applets themselves, but of the Java language, which was supposed to have been designed from the ground up for security.

The #2 reason is that you can only run an applet if a suitable JVM and plugin is installed in your client app (browser). Policy in many places these days is to have the browsers disable applets, thanks to reason #1.

The #3 reason is that applets - having been designed for security, despite the flaws, run in fairly tight sandboxes. They cannot access local files or devices unless they have been signed AND the client app has approved the signature. Which is usually too complex a process for most casual users to put up with.

And I can definitely sympathize with that last. My bank has just instituted some horrible new multi-step authentication scheme on their website which didn't work properly and has probably locked me out from my accounts. And I give security advice to banks for a living.
 
Les Morgan
Rancher
Posts: 711
17
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joseph Tagarelli wrote:i did it..but it doesnt run..i dont know


That's just it Joseph, you don't know, and we are guessing based on things we have seen in our experiences. What we don't know is if you even have the correct applet structure in place. You have stated time and time again that it runs in your IDE. That does not mean it is correct, all it means is your IDE can see enough to make it execute and give you the result.

You need to do what I originally suggested: start over with a small applet and get it to run in your browser. Then add a feature your app has and see if it runs still, keep going until you get to the point that you either have your full app, or it breaks. If it breaks see what your are doing wrong at that point. If it doesn't break, then seriously look at your original app and see what the difference is, but in any case, that is how you need to proceed.

If it's not worth it for you to go back and rework things from the beginning to see where your problem is, then seriously, why are you trying to pawn the debugging of your app onto us?

As you redevelop, be sure to debug frequently--every few lines. If you cannot debug 10 lines of code, then debug before you write 10 lines of code.

As I said when you tried to send me your entire code base: 1000 lines of code is only a waste of time and junk until it is debugged.
 
Paul Clapham
Sheriff
Posts: 21581
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joseph Tagarelli wrote:Yes..i must run it on browser.


Sometimes there's a requirement to use an applet because it can interact with Javascript in the HTML page which loads it. But that is not why you need to use an applet -- you already said that it works in the applet viewer, which doesn't support that. So it must be that your instructors are requiring you to use an applet. I would push back on that requirement. Ask them to justify requiring an applet instead of an application.

Even though there may still be a niche where applets are still used, there is just no excuse for requiring beginning programmers to work with applets. If your instructors are doing that, it makes me think that you are at a place which will provide you with a substandard education.
 
Les Morgan
Rancher
Posts: 711
17
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sometimes the reasoning behind the requirement is not the usefulness of the algorithm, but to see who will complete the assignment or not.

I once had a class, programming, that was by permission as it was a graduate course and I took it as an undergrad. The final requirement for all programs was that the solution was sitting on the instructor's podium before 10 after the hour--(official start of class). I had a friend that had the assignment on his desk, but forgot to put it on the podium. He received a 0 for his forgetfulness--even though it was a perfect solution. Was it fair or not, doesn't matter, it was the requirement and he lost a half letter grade on his class final evaluation because of it.

Paul Clapham wrote:
Even though there may still be a niche where applets are still used, there is just no excuse for requiring beginning programmers to work with applets. If your instructors are doing that, it makes me think that you are at a place which will provide you with a substandard education.
 
Campbell Ritchie
Sheriff
Posts: 51447
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Les Morgan wrote:. . . Was it fair or not, doesn't matter, it was the requirement . . .
I know it isn't a nice thing to say, but if it was a requirement and your colleague knew about that requirement, then the lost mark was fair.
A reminder from the teacher on the lines of, “You have 3½ seconds to hand in your assignments,” however, would have been nice.
 
Tony Docherty
Bartender
Posts: 3054
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
Les Morgan wrote:. . . Was it fair or not, doesn't matter, it was the requirement . . .
I know it isn't a nice thing to say, but if it was a requirement and your colleague knew about that requirement, then the lost mark was fair.
A reminder from the teacher on the lines of, “You have 3½ seconds to hand in your assignments,” however, would have been nice.

We are going way off subject here, in fact we are in danger of hijacking the OP's thread, but I have to disagree. I do not think that just because something is in the rules it is necessarily fair. Fairness is about what is reasonable and not what is regulation. It is clearly not fair that someone should receive a zero mark just because they forgot to hand in their assignment before the class started when they could show they had it with them. It may be considered fair to dock them marks or limit the maximum achievable mark to a bare pass but a zero mark is harsh. Having said that them is the rules and for a lot of people in positions of power the rules are the rules - but it still doesn't make it fair.
 
Tony Docherty
Bartender
Posts: 3054
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Joseph - Read the Java Applet tutorial in particular the section on deploying applets (https://docs.oracle.com/javase/tutorial/deployment/applet/deployingApplet.html) as it shows a way of deploying applets via a javascript deployment tool rather than directly using the applet tag (which I believe is no longer supported in HTML 5 nor by some browsers).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic