How can I put my jar file into my html?
I tried to use that:
<html>
<head>
</head>
<body>
<applet code=Tictactoe.class archive="Test.jar">
</applet>
</body>
</html>
My problem is that when Im trying to run my html code java is blocking my jar file.
Try to add your url (local or distant server url) in exception list on java settings panel.
Related
I get the ClassNotFoundException error when I make my html file with the code and jar file. Not sure why. Here's what I have:
<html>
<head>
<title>
Test Applet
</title>
</head>
<body>
<h2>Test Applet</h2>
<applet
code="Testing.class"
archive="myTestJar.jar"
width=550 height=300>
</applet>
</body>
</html>
I simply have the class in a jar file and tried to reference using archive but it doesn't work.
try this
<applet code=Testing.class
archive="myTestJar.jar"
width=550 height=300>
</applet>
The class has your main() I assume, the jar is the entire thing.
if,you're not taking packages into consideration. For instance, if the package is myPackage.vol3 then the line should read
<applet code="myPackage.vol3.Testing.class" archive="myTestJar.jar"
and put the html file in the project folded "INSIDE" the project folder.
I have the following projects
>projectJar
>projectWar
Inside projectJar I have a class that extends Applet, the class's name is com.me.test.TestApplet. Then in the war project I include the jar and create an HTML file like the following...
<HTML>
<HEAD>
<TITLE>A Simple Program</TITLE>
</HEAD>
<BODY>
<APPLET code="com.me.test.TestApplet.class"
archive="WEB-INF/lib/projectJar.jar" WIDTH=256 HEIGHT=240> </APPLET>
</BODY>
</HTML>
However, when I try to load the applet I get a class not found exception for TestApplet. Can anyone see what I am missing?
You cannot serve a "PATH" under "WEB-INF". Move your "projectJar.jar" to another folder, perhaps "/jar/porjectJar.jar".
I have this code:
document.write("<APPLET CODE='com/synergex/My.class' ARCHIVE='toc2.jar' ");
When my "toc2.jar" is in the same folder as the HTML - all works fine.
But when I put "toc2.jar" in another folder ("C:\MyJars"), I get ClassNotFoundException.
How can I "tell" the browser where to look for jars?
I tried to add "C:\MyJars" or "C:\MyJars\toc2.jar" to my CLASSPATH env variable, but it did not work.
You might be able to redirect the code base using an HTML base element.
For example, given the following BASE declaration and A declaration:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>Our Products</TITLE>
<BASE href="http://www.aviary.com/products/intro.html">
</HEAD>
<BODY>
<P>Have you seen our Bird Cages?
</BODY>
</HTML>
the relative URI "../cages/birds.gif" would resolve to:
http://www.aviary.com/cages/birds.gif
If not, there are only 2 options.
Leave the Jar in the same directory as the HTML.
Presuming that part of the script is the only thing you cannot change, add codebase='../path/' immediately after it, to tell the JRE to wherever the Jar is located.
As an aside:
CODE='com/synergex/My.class'
Should be:
CODE='com.synergex.My'
I am trying to create a table with sortable columns using a javascript library provided by this website. The web application is being created in Java and the table is created but not with the CSS style. I am 100% new to html and javascript and just started trying to learn things today.
I have placed the library in the same source folder as the JSP and also at the root of the project but both times the table is created in standard html format without the script formatting. How should I reference a Javascript library from a JSP in Java Web Application?
I have made some progress but I still cannot get it to work properly. This is my WelcomePage.jsp file:
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<%response.setHeader("Refresh", "5");%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>title</title>
<script type="text/javascript" src="sorttable.js"></script>
</head>
<body>
<p>Start</p>
<table class="sorttable">
<tr>
<td>text </td>
<td>text </td>
<td>text </td>
<td>text </td>
<td>text </td>
</tr>
</table>
</body>
</html>
I have tried placing it into the META-INF, WEB-INF, and the root folders none of them seem to work correctly. I have also attempted to add it to the web.xml file but nothing seems to work.
Some things I have already tried
Can not include javascript file from WEB-INF directory in JSP.
how to reference a java .class file from a JSP page?
Put it at the root of your application, or under a /scripts folder there. WEB-INF and META-INF are not accessible from outside.
If it is not accessible, then check the logs, try opening the js file manually in the browser, and check with Firebug (or similar tool) if there aren't javascript errors.
Then, if everything is ok, I suppose you need to invoke some function and pass the table id.
Since you are going to create web pages and you will probably need more js libraries, why don't you make a new folder inside the Web Pages one, solely for js?
I can't display images in JSP (and can't access other things like external Javascript/jQuery through SRC). The following JSP page just contains one <img> tag that can not display the image located by the SRC.
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form action="Temp.htm" method="post">
<img src="/images/temp.jpg" alt="Not available">
</form>
</body>
</html>
The images are in /WEB-INF/jsp/images. I have also tried to change the image location and ensure all the times that the path given to SRC is correct still it didn't. The same is possible with the applications without the framework. It works there perfectly. What am I missing here?
First, /WEB-INF is not accessible from the outside.
Second, if you use /images/temp.jpg, the browser will load images from the root of the web server, and not from the root of your web-app (which is deployed under a context path).
Use the JSTL <c:url> tag to generate absolute paths from the root of the web-app:
<img src="<c:url value='/images/temp.jpg'/>" alt=.../>
You cannot access files that are located in /WEB-INF/ directly from the web. The folder is protected from web access.
Locate your image files somewhere else. /images/temp.jpg is a absolute path, however you likely need a relative one. Point your image path to image/temp.jpg and place the images in the /images/ folder directly located under your web root. E.g. WebContent/images or src/main/webapp/images (depending on your web root).
Try put in the webapp directory, not WEB-INF. Obv. dont nest in the jsp dir.