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

ClassNotFoundException from HTML page

 
John Morgan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to run a simple Java file from an HTML page but I keep getting a ClassNotFoundException error.

HTML Page:


Java Page:


I am running this in eclipse with the following (pertinent only) file structure:

PROJECT
--->JavaResourches
--->--->src
--->--->--->javacode
--->--->--->--->DBStart.java
--->WebContent
--->--->region.html

I can get the java file to run with no problem but not calling it from the HTML page.

Any help would be appreciated as I have spent all day trying to get this working (the internet has been little to no help).

Thanks.
 
Stefan Evans
Bartender
Posts: 1807
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For embedding java in a web page in this manner you need an Applet, rather than an application.
It is a rather different model of things.

How are you running your class when it works?
Where have you put the compiled class file?

Are you actually wanting to run an applet as part of your web page? Or would a Servlet/JSP be more appropriate?
 
John Morgan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From what I am reading Applets are deprecated in HTML 5 and should not be used, instead the embedded method should be used... am I way off base on this?

I can run the DBStart.java file from eclipse no problem after looking at this last night I realized I do not have compiled code anywhere that I can see (next step to figure out in eclipse).

As for running in JSP or HTML ideally I want something that I can run on my tablet, phone or PC so either or will work (oh and I have a friend who runs a mac who also wants to use the program).
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your Java class is in the package LOTROjavacode. It's traditional to put it in a folder with that name. So you'd have /src/main/LOTROjavacode/DBStart in your directory structure. I would also expect you to need to put LOTROjavacode.DBStart.class in your code attribute.

 
Paul Clapham
Sheriff
Posts: 21581
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Morgan wrote:From what I am reading Applets are deprecated in HTML 5 and should not be used, instead the embedded method should be used... am I way off base on this?


From what I just read, it's only the <applet> tag which is deprecated in HTML 5. There are other ways to run applets including the way you are trying to run your application.

However you probably didn't realize that to run an applet, you need to have a JVM installed on the system where the applet will be running. (Do all those devices have JVMs?) You also need to secure the applet properly, which involves signing it with a certificate. If it's not a trusted certificate (translation: $$) then your users will have to go through an obscure process to say they trust your applet. And it looks like you want to have your applet access a database -- do you really want to run your database exposed to everybody on the web? Security advisors say you shouldn't do that either.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic