New to applet on tomcat
hi
i m new to applets and i m confused whr to put my class files for appley either in jsp folder or webinf/classes folder.
My applets is going to use sevral class do i have to put all in the same folder from whr my applet is starting.
plz help
i read the documentation of tomcat but it doesn't say whr to keep class files for applets.
I've just started with applets as well. I found that you have to put your .jar or .class files in the same directory as your html page.
Similar Messages
-
How to create a new virtual host under tomcat 4.1.x?
hi all
i need some help creating a new virtual host under tomcat 4.1.18!
that's what i do:
i'm using the web configuration, reacheable by typing "http://localhost:8080" and then clickign administration
i create a new host
name: www.class-site.it
application base: webapps\class-site
then i create the context:
document base: webapps\class-site
path: /
and nothing works!!!
anyone could help me?
if needed i can also post the server.xml file
thanx in advance for your help
sandroIt should look like this
<Host name="myvhost.com" debug="0" appbase="/my/path/to/webapps" unpackWars="true">
<Context path ="" docBase="ROOT" debug="0"/>
</Host>
This should be inside the <Engine> tags. You should be able to access a page by going to
http://myvhost.com:8080/index.jsp
Obviously you need index.jsp in /my/path/to/webapps/ROOT/index.jsp
Hope that helps -
Problem loading applet from tomcat
I am facing a problem loading the batik applet from tomcat. I have placed all the jar files of batik in ROOT directory in tomcat. Along with the folder containing the batik applet. Still i receive the following exception when trying to load the html page containing batik applet.
Applet tag in html page is:
<applet codebase = "." code="batik_applet.BatikApplet.class" name="myApplet" width="1600" height="1200" hspace="0" vspace="0" align="middle" archive="batik-swing.jar,batik-gvt.jar,batik-bridge.jar,xml-apis-ext.jar,batik-css.jar,batik-util.jar,batik-dom.jar,batik-svg-dom.jar,batik-anim.jar,batik-awt-util.jar,batik-codec.jar,batik-ext.jar,batik-extension.jar,batik-gui-util.jar,batik-parser.jar,batik-script.jar,batik-svggen.jar,batik-transcoder.jar,batik-xml.jar,js.jar,pdf-transcoder.jar,xalan-2.6.0.jar,xerces_2_5_0.jar,xml-apis.jar">
</applet>
I already have a folder named batik_applet containing BatikApplet.class in the ROOT directory.
========Exception===========
network: Connecting http://localhost:8080/servlet/batik_applet/BatikApplet.class with proxy=DIRECT
network: Connecting http://localhost:8080/servlet/batik_applet/BatikApplet.class with cookie "JSESSIONID=1A75299B77372108560B4DF8DC65A3A6"
network: Connecting http://localhost:8080/servlet/batik_applet/BatikApplet/class.class with proxy=DIRECT
network: Connecting http://localhost:8080/servlet/batik_applet/BatikApplet/class.class with cookie "JSESSIONID=1A75299B77372108560B4DF8DC65A3A6"
load: class batik_applet.BatikApplet.class not found.
java.lang.ClassNotFoundException: batik_applet.BatikApplet.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed.
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 10 more
basic: Exception: java.lang.ClassNotFoundException: batik_applet.BatikApplet.class
Any help would be appreciated.Assuming that your applet is not in a jar file (don't see a value for archive)
you have a file callsed ProcessStatus.class in a folder WEB-INF\classes relative to
the location of the jsp file.
So if the jsp file is in
myJSPFileFolder
the class should be in:
myJSPFileFolder\WEB-INF\classes
If you want to see when the jre is trying to load and where it it trying to load it from you
can inspect a full trace, to turn the full trace on (windows) you can start the java console, to be found here:
C:\Program Files\Java\j2re1.4...\bin\jpicpl32.exe
In the advanced tab you can fill in something for runtime parameters fill in this:
-Djavaplugin.trace=true -Djavaplugin.trace.option=basic|net|security|ext|liveconnect
if you cannot start the java console check here:
C:\Documents and Settings\userName\Application Data\Sun\Java\Deployment\deployment.properties
I think for linux this is somewhere in youruserdir/java (hidden directory)
add or change the following line:
javaplugin.jre.params=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
for 1.5:
deployment.javapi.jre.1.5.0.args=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
The trace is here:
C:\Documents and Settings\your user\Application Data\Sun\Java\Deployment\log\plugin...log
I think for linux this is somewhere in youruserdir/java (hidden directory)
The trace should show something like :
Caused by: java.io.FileNotFoundException: http://server/location/filename.class (The system cannot find the path specified) -
hai to everybody,
i am using tomcat-4.1.27 and j2sdk-1.4.0_01 and i have
been trying to load simple applet in HTML page by running tomcat server
but it is displaying at the status bar as class not found, but it is
showing the message Loading applet in my HTML page but the content in applet is not getting displayed.Please help me.
reg,
arvindhi,
i have attached code below
i am having a frame divided into two columns one is for html
one is for JSP
/*Frame.html */
<html>
<frameset cols="25% ,75%">
<frame src="App.html">
<frame src="Design.jsp">
</frameset>
</html>
In Design.jsp i am trying to display simple applet with a string message
the code is below
/*Design.jsp*/
<html>
<body>
Below it shows a simple applet
<h1>
<p align="center">
<center>
<jsp:plugin type="applet" code="SimpleBanner.class" width="300" height="150" codebase="arv/" jreversion="1.4">
</jsp:plugin>
</center>
</body>
</html>
In the above code the applet class file SimpleBanner is under the directory c:/arv/SimpleBanner and i am using tomcat 4.1.27 and j2sdk 1.4.0_01
/*SimpleBanner.java"*/
import java.applet.*;
import java.awt.*;
public class SimpleBanner extends Applet
public void init()
setBackground(Color.cyan);
setForeground(Color.red);
public void paint(Graphics g)
g.drawString("Henkel Spic",50,30);
when i try to run by giving url-http://localhost:8080/Frame.html
the page displays with applet size but not the string displaying inside
i don't know where the prob is.In the status bar it is showing
SimpleBanner.class not found.
help me.
reg arvind -
How to use JDK5.0 new feature code in tomcat 5.5.9, jsp files
Hi Everyone:
I am trying to use JDK5.0 new feature code -- for loop in jsp file , but got compile error , i try the same code in the java file which is working fine. i am wondering is it tomcat jsp compiler problem ?
following is my code and error msg
/* jdk 5.0 new feature, but cannot use in this jsp file, tomcat version? or setting problem ?
for (Thumbnail thumbnail : thumbnailList){
System.out.println(thumbnail.getAbsolutePath());
// following is working fine in jsp
Iterator iter = thumbnailList.iterator();
while(iter.hasNext()){
Thumbnail thumbnail = (Thumbnail) iter.next();
out.print(thumbnail.getAbsolutePath()+"<BR>");
%>
the error msg is :
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 16 in the jsp file: /test/testImageGallery.jsp
Generated servlet error:
Syntax error on token(s), misplaced construct(s)
An error occurred at line: 16 in the jsp file: /test/testImageGallery.jsp
Generated servlet error:
Syntax error on token ")", : expected
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:397)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
I am using fedora core 4 x64bit , tomcat 5.5.9,
java -version
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_04-b05, mixed mode)
tomcat settings
tomcat5/bin/catalina.sh run
Using CATALINA_BASE: /home/normal/tomcat5
Using CATALINA_HOME: /home/normal/tomcat5
Using CATALINA_TMPDIR: /home/normal/tomcat5/temp
Using JRE_HOME: /home/normal/jdk1.5.0_04The JDT compiler that Tomcat installs by default is only 1.4 compliant.
You can use ant instead:
remove the common/lib/jasper-compiler-jdt.jar file
place ant.jar file from the latest Ant distribution in the common/lib folder.
If you do this, you also need to use the "javac" argument to catalina.sh.
Documentation reference: http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jasper-howto.html -
Loading an applet in tomcat 4.x
Hi,
I have been reading the forums for a while trying to find an explanation to the problem I am having with no success.
The problem is that I have an applet that has a dynamic number of parameters. The number of parameters is determined by the contents of an application bean which is part of the environment.
The problem is that I can't get the applet to work using the <applet> tag. It seems that no matter what I set the codebase parameter to, I always get the dreaded "ClassDefNotFound Exception: FacilityApplet" in IE 6.0 or "ClassFormatError: Bad Major Version Number" exception in Netscape 4.79.
I am using JDK 1.4_0_01 and Tomcat 4.1.12 and my application (oam), context is organized as follows:
webapps/
oam
WEB-INF
classes
lib
applets
facility
jsp
html
index.html
I have jarred the applet into a file called FacilityApplet.jar and stored it into the oam/applets/facility directory. The contents of the jar file follows:
META-INF/
META-INF/MANIFEST.MF
FacilityApplet.class
common/DataEvent.class
common/Facility.class
common/Link.class
DialogBox/
DialogBox/DialogBox$CloseDialog.class
DialogBox/DialogBox$CloseWindow.class
DialogBox/DialogBox.class
The following is the contents of my jsp page that attempts to load the applet.
<html>
<head>
<!-- Ensure the HTTP Server Does Not Save this Page in Cache -->
<meta HTTP-EQUIV=Pragma CONTENT=no-cache >
<title> Status Page </title>
</head>
<%@ page import="javaBeans.SettingsBean" %>
<jsp:useBean id="settings" class="SettingsBean" scope="application" />
<body BGCOLOR="honeydew" LINK="Blue" TEXT="black" VLINK="Red">
<h1>
Application Status
</h1>
<%
// Make sure we have a good bean to work with
if (settings.getTotalFacilities() != 0) {
%>
<applet
archive="FacilityApplet.jar"
codebase="http://localhost:8080/oam/applets/facility"
code="FacilityApplet.class"
width="300" height="150" >
<param name="PORT" value="8939" >
<%
for (int i = 0;i < settings.getTotalFacilities();i++) {
%>
<param name="FAC_<%= i %>" value="<%= settings.getFacilityName(i) %>">
<param name="STATE_<%= i %>"
value="<%= settings.getFacility(i).getState() %>">
<% } %>
</applet>
<% }
else {
%>
<h2 align="center"> No Facilities to Display </h2>
<% } %>
</body>
</html>
Here are the values for codebase that I have tried so far:
codebase="<%= request.getContextPath() %>/applets/facility"
codebase="http:localhost:8080/oam/applets/facility"
codebase="../applets/facility"
I also expanded the jar file under the applets/facility directory with the same results. I also copied all the class files in the same directory as my jsp file, codebase="facility", with the same results.
Now, if I use the <jsp:plugin> tag the applet loads with no problems using codebase="<%= request.getContextPath() %>/applets/facility", but that does not allow me to set my applet parameters dynamically. It works fine if I hardcode my parameters inside the <jsp:param> tag. However, I can explain this since it will require the JSP compiler to do multiple passes over the source code, and I don't think it does that.
My PC has the latest version of the JRE plugin 1.4.X.
Any help will be greatly appreciated.
MaizoFolks,
I hate to follow up my own posting but I figured out the problem. My browser was using its own JVM, which of course was an old one.
Sorry to waste these resources
Maizo -
I'm trying to use an applet in a JSP page running on a tomcat server. My problem is that while the page loads fine, none of the applets (there are 3) can find their code, which I have put into WEB-INF/classes and WEB-INF/lib as .class and .jar files respectively. What do I need to do to make these classes visible?
Yes, i use this code
<jsp:plugin type="applet" code="applets.loadbsk.LoadBasket.class"
archive="/myDirectory/applets.jar"
width="380" height="280"
jreversion="1.3" name="LoadBasket">
<jsp:params>
<jsp:param name="MyParamId" value="<%= sParamId %>" />
</jsp:params>
</jsp:plugin> -
Hello Javaranchers
I have made a simple applet which actually works fine on my ie6. But when I deploy all source to my Tomcat 4.1 I cannot get it to work.
I have places my applet source in a package called dk.chatrmi. My class file is called ChatImpl.class. I have placed the applet in the classes dir of my Tomcat. The following is my html file, which I have placed in the root of my Tomcat "examples". This is the content of the file:
<html>
<applet code="dk.chatrmi.ChatImpl.class" codebase="http://localhost:8080/examples/servlet" width=800 height=400></applet>
</html>
I have added the full path to the codebase attr. but still I cannot get it to work.
I have sdk 1.4 installed on my computer.
I get the following error in my Java console:
PLEASE HELP!!!
load: class dk.chatrmi.ChatImpl.class not found.
java.lang.ClassNotFoundException: dk.chatrmi.ChatImpl.class
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:153)
at sun.plugin.security.PluginClassLoader.findClass(PluginClassLoader.java:168)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:114)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:506)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:566)
at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1775)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:495)
at sun.applet.AppletPanel.run(AppletPanel.java:292)
at java.lang.Thread.run(Thread.java:536)
Caused by: java.io.IOException: open HTTP connection failed.
at sun.applet.AppletClassLoader.getBytes(AppletClassLoader.java:252)
at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:42)
at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:143)
at java.security.AccessController.doPrivileged(Native Method)
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:140)
... 10 more
Regards RalphYour codebase doesn't look right -- probably should read (with an s at the end):
codebase="http://localhost:8080/examples/servlets"
If that doesn't correct the problem, make sure that the following is a valid path:
examples/servlet/dk/chatrmi
to a file named ChatImpl.class
;o)
V.V. -
I have .jsp page.I use tomcat server .When session is valid and i print sessionid in jsp using function session.getId() it print session id but when session is expire then new session id is printed .I didn't understand why this behavior.I set session timeout to 5 sec fro debugging perpose .what i expect is
that session becomes null.My code is
<%
UserData ud=null;
if(session == null){
}else{
if(session != null){
out.println("BEFORE :" + session.getId() + "<BR>");
//ud=(UserData) session.getAttribute("ClientObject");
out.println("AFTER :" + session.getId() + "<BR>");
if(ud == null){
//response.sendRedirect("../ServletLogout");
//response.sendRedirect("www.google.com");
out.println("UD==NULL" + session.getId() + "<BR>");
out.println("Welcome to tracking page");
%>
Thanks
VijayI imagine that /test and /TestSession/test/test.jsp fall under different web app context paths.
When the Servlet container creates a JSESSIONID cookie to track the session, it includes a path attribute. The path attribute controls in which requests the browser will send the cookie. By default, the path attribute is set to the web app context path. If the context path is /TestSession, the path attribute will be set to /TestSession and the browser won't include the cookie when it makes requests to /test.
You can override the cookie path with a sun-web.xml deployment descriptor:
<sun-web-app>
<session-config>
<cookie-properties>
<property name="cookiePath" value="/"/>
</cookie-properties>
</session-config>
</sun-web-app>You could also rewrite the outbound Set-cookie: header with an Output directive in obj.conf.
A simpler, less brittle solution would be to redirect requests for /test instead of restarting them. -
New to Applets: Problems wiht writing to files and with scroll panes.
Hi, I've recently graduated from university and so I have limited experience in java programming and I'm having some trouble with JApplets (this is the first time I've made one). I'm trying to make a simple program that will allow users to pick one of a few background images from a list (a list of jpanels within a scroll pane) then at the click of a button will output a CSS with the background tag set to the image location. This is for use on a microsoft sharepoint site where each user has a My-Sit area which I want to be customizable.
So far I've been creating this program as an application rather than a JApplet and just having another class that extends the JApplet Class which then displays the JFrame from the GUI Class. This initially didnt work because I was trying to add a window to a container so I kept programming it as an application until I got it working before trying to convert it to a JApplet. I solved the previous problem by changing my GUI class to extend JPanel instead of JFrame and it now displays correctly but with a coupe of issues.
Firstly the applet will not create/write to the CSS file. I read that applets couldnt read/write to the users file system but they could to their own. The file I wish to write to is kept on the same machine as the applet so I'm not sure why this isn't working.
Secondly the scroll panel is no longer working properly. This worked fine when I was still running the program as an application when the GUI still extended JFrame instead of JPanel (incidentally the program no longer runs as an application in this state) but now the scroll bar does not appear. This is a problem since I want the applet to remain the same size on the page even if I decide to add more backgrounds to the list. I tried setting the applet height/width to smaller values in the html file to see if the scroll bar would appear if the area was smaller than the GUI should be, but this just meant the bottom off the applet was cut off.
Could anyone offer any suggestion as to why these thigns arnt working and how to fix them? If necessary I can post my source code here. Thanks in advance.Ok, well my program is made up of 4 classes, I hope this isnt too much to be posting. If any explaination is needed then I'll post that next. Theres lots of print lines scattered aroudn due to me trying to fix this and theres some stuff commented out from when the program used to be an application isntead of an applet.
GUI Class, this was the main class until I made a JApplet Class
public class AppletGUI extends JPanel{
*GUI Components*
//JFrames
JFrame mainGUIFrame = new JFrame();
JFrame changeBackgroundFrame = new JFrame();
//JPanels (Sub-panels are indented)
JPanel changeBackgroundJP = new JPanel(new BorderLayout());
JPanel changeBackgroundBottomJP = new JPanel(new GridLayout(1,2));
JPanel backgroundJP = new JPanel(new GridLayout(1,2));
JPanel selectBackground = new JPanel(new GridLayout(1,2));
//Jbuttons
JButton changeBackgroundJB = new JButton("Change Background");
JButton defaultStyleJB = new JButton("Reset Style");
//JLabels
JLabel changeBackgroundJL = new JLabel("Choose a Background from the Menu");
JLabel backgroundJL = new JLabel();
//JScrollPane
JScrollPane backgroundList = new JScrollPane();
JPanel backgroundListPanel = new JPanel(new GridLayout());
//Action Listeners
ButtonListener bttnLstnr = new ButtonListener();
//Controllers
CSSGenerator cssGenerator = new CSSGenerator();
Backgrounds backgroundsController = new Backgrounds();
backgroundMouseListener bgMouseListener = new backgroundMouseListener();
//Flags
Component selectedComponent = null;
*Colour Changer*
//this method is used to change the colour of a selected JP
//selected JPs have their background darkered and when a
//different JP is selected the previously seleced JP has its
//colour changed back to it's original.
public void changeColour(JPanel theJPanel, boolean isDarker){
//set selected JP to a different colour
Color tempColor = theJPanel.getBackground();
if(isDarker){
tempColor = tempColor.darker();
else{
tempColor = tempColor.brighter();
theJPanel.setBackground(tempColor);
//also find any sub-JPs and change their colour to match
int j = theJPanel.getComponents().length;
for(int i = 0; i < j; i++){
String componentType = theJPanel.getComponent(i).getClass().getSimpleName();
if(componentType.equals("JPanel")){
theJPanel.getComponent(i).setBackground(tempColor);
*Populating the GUI*
//backgroundList.add();
//Populating the Backgrounds List
*Set Component Size Method*
public void setComponentSize(Component component, int width, int height){
Dimension tempSize = new Dimension(width, height);
component.setSize(tempSize);
component.setMinimumSize(tempSize);
component.setPreferredSize(tempSize);
component.setMaximumSize(tempSize);
*Constructor*
public AppletGUI() {
//REMOVED CODE
//AppletGUI.setDefaultLookAndFeelDecorated(true);
//Component Sizes
//setComponentSize
//Adding Action Listeners to Components
System.out.println("adding actions listeners to components");
changeBackgroundJB.addActionListener(bttnLstnr);
defaultStyleJB.addActionListener(bttnLstnr);
//Populating the Change Background Menu
System.out.println("Populating the window");
backgroundsController.populateBackgroundsData();
backgroundsController.populateBackgroundsList();
//loops to add background panels to the JSP
ArrayList<JPanel> tempBackgroundsList = new ArrayList<JPanel>();
JPanel tempBGJP = new JPanel();
tempBackgroundsList = backgroundsController.getBackgroundsList();
int j = tempBackgroundsList.size();
JPanel backgroundListPanel = new JPanel(new GridLayout(j,1));
for(int i = 0; i < j; i++){
tempBGJP = tempBackgroundsList.get(i);
System.out.println("Adding to the JSP: " + tempBGJP.getName());
//Add Mouse Listener
tempBGJP.addMouseListener(bgMouseListener);
backgroundListPanel.add(tempBGJP, i);
//set viewpoing
backgroundList.setViewportView(backgroundListPanel);
/*TESTING
System.out.println("\n\n TESTING!\n Printing Content of SCROLL PANE \n");
j = tempBackgroundsList.size();
for(int i = 0; i < j; i++){
System.out.println(backgroundList.getComponent(i).getName());
changeBackgroundJP.add(changeBackgroundJL, BorderLayout.NORTH);
changeBackgroundJP.add(backgroundList, BorderLayout.CENTER);
//changeBackgroundJP.add(tempBGJP, BorderLayout.CENTER);
changeBackgroundJP.add(changeBackgroundBottomJP, BorderLayout.SOUTH);
changeBackgroundBottomJP.add(changeBackgroundJB);
changeBackgroundBottomJP.add(defaultStyleJB);
System.out.println("Finsihed populating");
//REMOVED CODE
//adding the Background Menu to the GUI and settign the GUI options
//AppletGUI.setDefaultLookAndFeelDecorated(true);
//this.setResizable(true);
//this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocation(500,500);
this.setSize(400,300);
this.add(changeBackgroundJP);
//REMOVED CODE
*Main Method*
public static void main(String[] args){
System.out.println("Creating GUI");
AppletGUI theGUI = new AppletGUI();
theGUI.setVisible(true);
System.out.println("GUI Displayed");
*Button Listener Inner Class*
public class ButtonListener implements ActionListener{
//check which button is clicked
public void actionPerformed(ActionEvent event) {
AbstractButton theButton = (AbstractButton)event.getSource();
//Default Style Button
if(theButton == defaultStyleJB){
System.out.println("Default Style Button Clicked!");
//Change Background Button
if(theButton == changeBackgroundJB){
System.out.println("Change Background Button Clicked!");
String backgroundURL = cssGenerator.getBackground();
if(backgroundURL != ""){
cssGenerator.setBackgroundChanged(true);
cssGenerator.setBackground(backgroundURL);
cssGenerator.outputCSSFile();
System.out.println("Backgroudn Changed, CSS File Written");
else{
System.out.println("No Background Selected");
*Mouse Listener Inner Class*
public class backgroundMouseListener implements MouseListener{
public void mouseClicked(MouseEvent e){
//get component
JPanel tempBackgroundJP = new JPanel();
tempBackgroundJP = (JPanel)e.getComponent();
System.out.println("Background Panel Clicked");
//change component colour
if(selectedComponent == null){
selectedComponent = tempBackgroundJP;
else{
changeColour((JPanel)selectedComponent, false);
selectedComponent = tempBackgroundJP;
changeColour((JPanel)selectedComponent, true);
//set background URL
cssGenerator.setBackground(tempBackgroundJP.getName());
public void mousePressed(MouseEvent e){
public void mouseReleased(MouseEvent e){
public void mouseEntered(MouseEvent e){
public void mouseExited(MouseEvent e){
}JApplet Class, this is what I plugged the GUI into after I made the change from Application to JApplet.
public class AppletTest extends JApplet{
public void init() {
System.out.println("Creating GUI");
AppletGUI theGUI = new AppletGUI();
theGUI.setVisible(true);
Container content = getContentPane();
content.setBackground(Color.white);
content.setLayout(new FlowLayout());
content.add(theGUI);
AppletGUI theGUI = new AppletGUI();
theGUI.setVisible(true);
setContentPane(theGUI);
System.out.println("GUI Displayed");
public static void main(String[] args){
AppletTest at = new AppletTest();
at.init();
at.start();
}The CSS Generator Class. This exists because once I have the basic program working I intend to expand upon it and add multiple tabs to the GUI, each one allowing the user to change different style options. Each style option to be changed will be changed wit ha different method in this class.
public class CSSGenerator {
//Variables
String background = "";
ArrayList<String> backgroundCSS;
//Flags
boolean backgroundChanged = false;
//Sets and Gets
//For Variables
public void setBackground(String theBackground){
background = theBackground;
public String getBackground(){
return background;
//For Flags
public void setBackgroundChanged(boolean isBackgroundChanged){
backgroundChanged = isBackgroundChanged;
public boolean getBackgroundChanged(){
return backgroundChanged;
//background generator
public ArrayList<String> backgroundGenerator(String backgroundURL){
//get the URL for the background
backgroundURL = background;
//creat a new array list of strings
ArrayList<String> backgroundCSS = new ArrayList<String>();
//add the strings for the background options to the array list
backgroundCSS.add("body");
backgroundCSS.add("{");
backgroundCSS.add("background-image: url(" + backgroundURL + ");");
backgroundCSS.add("background-color: #ff0000");
backgroundCSS.add("}");
return backgroundCSS;
//Write CSS to File
public void outputCSSFile(){
try{
//Create CSS file
System.out.print("creating file");
FileWriter cssWriter = new FileWriter("C:/Documents and Settings/Gwilym/My Documents/Applet Data/CustomStyle.css");
System.out.print("file created");
System.out.print("creating buffered writer");
BufferedWriter out = new BufferedWriter(cssWriter);
System.out.print("buffered writer created");
//check which settings have been changed
//check background flag
if(getBackgroundChanged() == true){
System.out.print("retrieving arraylist");
ArrayList<String> tempBGOptions = backgroundGenerator(getBackground());
System.out.print("arraylist retrieved");
int j = tempBGOptions.size();
for(int i = 0; i < j ; i++){
System.out.print("writing to the file");
out.write(tempBGOptions.get(i));
out.newLine();
System.out.print("written to the file");
out.close();
}catch (Exception e){//Catch exception if any
System.out.println("Error: Failed to write CSS file");
/** Creates a new instance of CSSGenerator */
public CSSGenerator() {
}The Backgrounds Class. This class exists because I didnt want there to just be a hardcoded lsit of backgrounds, I wanted it to be possible to add new ones to the list without simply lettign users upload their own images (since the intended users are kids and this sharepoint site is used for educational purposes, I dont want them uplaoded inapropraite backgrounds) but I do want the site admin to be able to add more images to the list. for this reason the backgrounds are taken from a list in a text file that will be stored in the same location as the applet, the file specifies the background name, where it is stored, and where a thumbnail image is stored.
public class Backgrounds {
//Array Lists
private ArrayList<JPanel> backgroundsList;
private ArrayList<String> backgroundsData;
//Set And Get Methods
public ArrayList getBackgroundsList(){
return backgroundsList;
//ArrayList Population Methods
public void populateBackgroundsData(){
//decalre the input streams and create a new fiel hat points to the BackgroundsData file
File backgroundsDataFile = new File("C:/Documents and Settings/Gwilym/My Documents/Applet Data/BackgroundsData.txt");
FileInputStream backgroundsFIS = null;
BufferedInputStream backgroundsBIS = null;
DataInputStream backgroundsDIS = null;
try {
backgroundsFIS = new FileInputStream(backgroundsDataFile);
backgroundsBIS = new BufferedInputStream(backgroundsFIS);
backgroundsDIS = new DataInputStream(backgroundsBIS);
backgroundsData = new ArrayList<String>();
String inputtedData = null;
//loops until it reaches the end of the file
while (backgroundsDIS.available() != 0) {
//reads in the data to be stored in an array list
inputtedData = backgroundsDIS.readLine();
backgroundsData.add(inputtedData);
//TESTING
System.out.println("\n\nTESTING: populateBackgroundsData()");
int j = backgroundsData.size();
for(int i = 0; i < j; i++){
System.out.println("Index " + i + " = " + backgroundsData.get(i));
System.out.println("\n\n");
//close all stremas
backgroundsFIS.close();
backgroundsBIS.close();
backgroundsDIS.close();
} catch (FileNotFoundException e) {
System.out.println("Error: File Not Found");
} catch (IOException e) {
System.out.println("Error: IO Exception Thrown");
public void populateBackgroundsList(){
backgroundsList = new ArrayList<JPanel>();
int j = backgroundsData.size();
System.out.println("number of backgrounds = " + j);
backgroundsList = new ArrayList<JPanel>();
for(int i = 0; i < j; i++){
String tempBackgroundData = backgroundsData.get(i);
JPanel backgroundJP = new JPanel(new GridLayout(1,2));
JLabel backgroundNameJL = new JLabel();
JLabel backgroundIconJL = new JLabel();
//split the string string and egt the background name and URL
String[] splitBGData = tempBackgroundData.split(",");
String backgroundName = splitBGData[0];
String backgroundURL = splitBGData[1];
String backgroundIcon = splitBGData[2];
System.out.println("\nbackgroundName = " + backgroundName);
System.out.println("\nbackgroundURL = " + backgroundURL);
System.out.println("\nbackgroundIcon = " + backgroundIcon + "\n");
backgroundNameJL.setText(backgroundName);
backgroundIconJL.setIcon(new javax.swing.ImageIcon(backgroundIcon));
backgroundJP.add(backgroundNameJL);
backgroundJP.add(backgroundIconJL);
backgroundJP.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
//Name the JP as the background URL so it can be found
//May be useful sicne the data file may need to contain 3 fields in future
//this is incase the preview image (icon) is different from the acctual background
//most liekly in the case of more complex ppictures rather then repeating patterns
backgroundJP.setName(backgroundURL);
//Add the JP to the Array List
backgroundsList.add(backgroundJP);
//TESTING
System.out.println("\n\nTESTING: populateBackgroundsList()");
j = backgroundsList.size();
for(int i = 0; i < j; i++){
System.out.println("Index " + i + " = " + backgroundsList.get(i));
System.out.println("\n\n");
}So thats my program so far, if theres anythign that needs clarifying then please jsut ask. Thank you very much for the help! -
How to deploy jfxpanel with applet to Tomcat.....
I want to deploy jfxpanel with in a panel in applet. But a message appear that jfxpanel class not found. when i include the jar file jfxrt.jar, tomcat isn't loaded this file. After that i use the environment varibale and set the class path in javafx runtime lib. but still unable the same exception appeared. I want your help to solve this issue..
Thank you igor. Your reply resolve most of the issues.. of my application. when i installed javafx runtime alone . the application link http://javafx.com/about-javafx/ that you have given me works fine but it changes the jre or something else... that my own developed application not able to make connection with the tomcat server. when i reinstalled jdk6u29 my application works fine and the link above is not working.
After that without installing the runtime of javafx 2.0 i install the javafx sdk 2.0.1 the runtime installed by itself. but the same link throws the same exception the exception as after launching my own client application.
java.lang.RuntimeException: java.lang.NoClassDefFoundError: javafx/embed/swing/JFXPanel
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: javafx/embed/swing/JFXPanel
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javafx.embed.swing.JFXPanel
at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source)
at sun.plugin2.applet.JNLP2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 20 more
Exception: java.lang.RuntimeException: java.lang.NoClassDefFoundError: javafx/embed/swing/JFXPanel
After installing the runtime of javafx again the link worked successfully and my client application application didn't able to make connection with tomcat.
is there any way to merge jre with javafx runtime. and with loading of jre , javafx runtime loaded by itself.???? -
After frustrating myself to no end trying to make this simple thing I have tried a different approach. Here is my code...
import java.awt.*;
import javax.swing.JPanel;
import javax.swing.JLabel;
public class SAComp extends java.awt.Frame{
// this will become an applet.
// first I want to make it into a stand alone.
JLabel completed;
JLabel incomplete;
int height = 75;
int maxWidth = 400;
public SAComp(){
init();
public static void main (String args[]){
SAComp tmp = new SAComp();
public void init(){
initComponents();
completed.setVisible(true);
incomplete.setVisible(true);
setBounds(100,100,400,400);
private void initComponents(){
// contains 2 elements.
// Flow Layout...
completed = new JLabel();
incomplete = new JLabel();
setBackground(java.awt.Color.black);
setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 5));
completed.setSize(100,height);
incomplete.setSize(maxWidth - completed.getWidth(),height);
incomplete.setBackground(java.awt.Color.red);
add(incomplete);
completed.setBackground(java.awt.Color.green);
add(completed);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
pack();
show();
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
}When I tried making the two components Labels they don't display. When I try making them panels they display as little squares regardless of setting the size.
I am trying to make a progress meter. The left side represents the completed items, the right represents the incompleted.
Can anyone help?
Thanks againI apologize for the lack of knowlege on my part. I normally write db apps. This si a quick one off for a friend.
I'll look into progressBar. I hadn't heard of it.
As far as the labels vs panels I was simply trying to get 2 elements to display on the page such that they can be resized to represent a progress bar.
Oh, the multi init methods is a holdover from some other code. I was trying to write this as an applet but when I didn't work I switched it to a stand alone app for quicker testing. Sorry for the sloppy code. You know how it gets when something that should be simple turns into a mess and you thrash about trying different things.
Thanks for all of the input. -
Programming new shutdown applet on Cinnamon (systemd related)
Hello everyone,
I have installed Cinnarch, and I wanted to use the shutdown applet but its code doesn't work if you are using systemd. So I planned to program the new code to be compatible with systemd, but I don't know how to do it. The code that doesn't work is the following:
$ dbus-send --system --print-reply --system --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
So, what would be the code for shutdown with systemd.
Thanks in advance.I am afraid there may be differences between Cinnarch and Arch in this regards. As such there are no guarantees an advice from Arch users would be of help. Even more importantly, we cannot run run risk that an advice that is relevant to Cinnarch would not be applicable, or worse, wrong when it comes to Arch Linux users and the members of these forums.
That is why we do not provide support for other operating systems
Please ask this question on the Cinnarch forums. -
Reloading a new JSP/Jar in Tomcat Server
HI,
I face these problems now.
My environment is Oracle Jdev 3.2.3 for JSP development. Tomcat4.0.1 as Application server plugged into IIS webserver and Using oracle 8i as the database
1. Whenever I update my JSP's and Application jar files, I copy from staging area to the deployment Tomcat Server application specific directories. The files are getting copied(overwritten). After that when i try to access my context/application in Tomcat server, my browser simply tries to browse and doesn't bring up the homepage of my application(say index.jsp).
I need to stop the tomcat server and restart again. Then I get it.
Is there anyone who came across this error and possibly help me to solve this?
2. I have a JSP (say emplist) which shows all the employees details with empno, ename, depyno and sal as 4 columns.
I have a up and down arrow images near the column names. Upon clicking it, it will call the same page and sort the column either desc or asc based on the previous display order. The column on which the Arrow button displayed is stored in session variable.
This sorting in JSP perfectly works in JDeveloper and when i run using WebToGo Server. But when i deployed in Tomcat,This sorting doesn't work.
The page simply stands. and when i go back and front browsing my other pages of application, i lose the position of the arrow button and it behaves unexpectedly by showing up in some other columns.
is there any reason for this kind of behaviour?
3. In my JSP files, I log the user actions into a text file in the server. IN WTG, I am able to specify the path of the output directory.
But in Tomcat Server, by default the output files are getting created in C:/Tomcat/bin directory.
I donno how to set an output directory, where the files will be written to and set an input directory from where my custom application properties files will be read from.
Can anyone help me in telling in which file and what attributes, i need to set the input and output directory path in Tomcat Server?
Can someone help me in giving suggestions or solutions for the above problems?
Thanks a lot in advance.
Thanks
HariI added a Context Tag in server.xml file in the Host Tag
<Context docBase="struts-blank">
</Context>and so following comes up in the Server Console Window
INFO: Starting service Catalina
Feb 7, 2005 11:06:30 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.2
Feb 7, 2005 11:06:30 PM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
Caused by: java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:396)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardConte
xt.java:3707)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3
934)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:420
at org.apache.catalina.core.StandardService.start(StandardService.java:4
50)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:196
7)
at org.apache.catalina.startup.Catalina.start(Catalina.java:541)
... 6 moreThanks in advance
CSJakharia -
Here is one method from the class:
public void update(Graphics g) {
Dimension d = size();
int w = sky.getWidth(this);
int h = sky.getHeight(this);
// If we've loaded the moving image, draw it.
if ((w > 0) && (h > 0)) {
g.drawImage(sky, ((frameNumber*12) % (w+d.width))-w,
(d.height - h), this);
g.drawImage(bird,x,y,this);
Okay. The applet runs. However, when the sky moves across as the background, as soon as it shifts completely off the view, it gets all wierd and blurry. Then, when it shifts in again, it goes back to normal. It's supposed to go from left to right, start again at the left again, and then go right again...going only right...How do I stop it from getting all wierd?
Also, the bird image gets all staticky...all I do is increment/decrement the x and y (private int variables) in the keyPressed method (with a multi-way if). I read somewhere the solution to this problem is double-buffering...which I don't understand how to implement with my images....Sky and bird are both GIFs...
Edited by: LinksApprentice on May 17, 2008 7:49 AMIf you don't get a great answer (or even if you do) a great resource that I suggest you read is an article entitled [How To Ask Questions The Smart Way|http://www.catb.org/~esr/faqs/smart-questions.html] . It will tell you how to formulate your questions so that the folks here will be better able to answer them. Good luck.
Maybe you are looking for
-
Deleting iCloud songs from iPod Touch? Please!
Hi, The quick way of saying what I'm trying to do is delete and iCloud song from my iPod and the photo at the bottom will give you an idea of what Im talking about but... I was working with an Apple person over the phone last night for my macbook but
-
Printing to Acrobat 9 Pro renders giberish text
When printing from the net to my Acrobat 9 Pro the image output is perfect yet the text is all giberish. Can anyone help? Thanks in advanced. Francisco De La Chesnaye [email protected]
-
HT1430 hi my iphone got locked and message appears iphone is diabled connect to itunnes?
hi i have a problem with iphone4s which got locked and cant open. message says iphone is disabled. conect to iTunes please help me resolve this issue and unlock my iphone rgds paul pereira dxb
-
HT4972 I'm getting an error code 9006 when trying to update
I've tried updating my IPad 2 more then 5 times. I'm receiving an error code 9006 each time and has stopped teh update. I have re-installed Itunes on my computer and have restrated IPad multiple times. Need help please, very frusturated.
-
How do I reduce the amount of Gbs that my music takes up
I have roughly 2400 songs and it's taking 16 Gbs which I cannot load onto my iPhone any way I can reduce the file size without re-importing the songs?