Jar files and applet
My applet class is using other classes in my package,
So do i need to create a jar file and specify that jar file in <applet archieve = :myjar.jar"
I did created the jar file , but its not loading up, the browser just says Loading java applet, what might be the reason, does it depends on size of jar file?
or my tags are wrong.
my applet tag is
<html>
<applet archive = "myjar.jar"
code = "front.class"
width.. >
the front.class file is also in myjar.jar.
Any help....
Also one more question,
Can i call other applets within one applet class.
I have a gui, when a particular button is clicked on applet
i want to go to other applet, so how should i call it in that buttons action listner?
And in my applet class i am using one other class from my package which actually coonects to databse through JDBC. now say i have a button on my applet whihc says "Connect", and when that button is clicked then I created object of my other class which makes connection
through databse. So will this work from applet?
Thanks
You didn't show all of your applet tag, but it should look like this:
<HTML>
<APPLET CODE = front.class, ARCHIVE = myjar.jar, width = ???, height = ???>
</APPLET>
</HTML>
Assuming your applet is not crashing, this should load it. I recommend using the appletviewer tool in the JDK, it provides more detailed error messages. I hope this works for you.
Now inter-applet communication. This is forbidden, sorry. However, if you really want to get fancy; remember that all applets can communicate back to the host from which they came. So if you want to build a small server on your host machine which all your applets log into, they can then communicate with each other through the server.
Similar Messages
-
Three questions about signed jar file and applet
I use three signed jar file. Each of them signed by different certificate. First of JARs contain applet class. When I start applet from html page I see message “This applet was signed by…… but Java cannot verify it… Do you trust…?”. All times I press “Yes I trust” and after this questions applet stop to work end exit. If I use only one certificate for signing of three JARs then applet continue to work after question. 1) What should I do to fix this bug? 2) Is it any method to check from applet that user press Trust button? Is it any method to emulate work of SecurityManager to check that Certificate object is trusted (I want do call some method check(Certificate) and if certificate is not trusted I want to see message with question: “Do you want to trust this certificate” and so on)?
Hello Jarman,
1. If I have a signed jar file, then as long as the
certificate is recognised as trusted that applet can
run as a fully trusted application on the client
machine. So I should not have to add lines such as
permission java.lang.RuntimePermission
"readFileDescriptor", "read" ;
permission java.lang.RuntimePermission
"writeFileDescriptor", "write" ;
to my java.policy file. true/false ?true
2. If I am running a signed jar file in the Java
plugin then I do not need to have a verisign or thawte
certificate (however to allow my certificate to be
accepted I do have to import it into the cacerts file
on the client machine). True/false?true
3. Following on from question 2, if I want to be able
to run an applet on a client machine, without messing
around with ANY files on those machines, I need a
verisign or thawte certificate. True/false?true
4. (And finally) Apart from a security exception
saying that I need to add one of the lines like those
of question 1, is there any way I can get other debug
information as to why the signed jar file is not being
recognised as signed?No. This could be a problem of importing your certifcate into the wrong place.
The information on the following link is a little bit dated but it helped me to successfully install a testcertificate and sign an applet with it.
http://www.suitable.com/Doc_CodeSigning.shtml -
I'm completely new to the whole .jar thing so i was wondering, after i package an applet and its respected classes within a .jar archive. what information should be in the manifest file?
lets say the applet is called, AppletText.class , and it makes use of the classTest.class class.
im using netbeans and i made it generate manfest file automaticaly. this is what it gives.
Manifest-Version: 1.0
Created-By: NetBeans IDE
Specified-By: TestJar.jarContent
when i click to execute the jar, i get an error message
Failed to load Main-Class manifest attribute from
C:\Documents and Settings\xxxxxxxxxx\xxxxxxxxxxxxx\xxxxxxxxxxx\AppletJartest.jar
x's are used to censor filenames
so how do i make it execute the way i want? (execute the applet and allow use of the class)Just for reference may be. Sorry if it does not met your need..:
How to jar a packaged java class? (I write this so I don't forget to create jar file again :-( ..)
Consider the package is under the folder c:\classes and you have folder ml where you write several packages such as
- package ml.gui (c:\classes\ml\gui)
- package ml.algorithm (c:\classes\ml\algorithm)
- package ml.utils (c:\classes\ml\util)
- etc..
- and a main class, lets say "tool" as package under ml\gui (package ml.gui.tool)
so the folder c:\classes actually contains folder ml and ml has another folders.
Step to create packaged class jar:
Step1: Create a "Manifest.mf" file at least contains the following text:
Manifest-Version: 1.0
Main-Class: ml.gui.tool
Created-By: XXXXXX
Note:
* tool is the main class that will be executed
* the purpose of manifest can be found anywhere
in internet
Step2: Open MSDOS to c:\classes
Step3:
Execute the following command:
jar -cvfm <jarfiletobecreated.jar> Manifest.mf <packaged class>
In my case, the command is:
jar -cvfm ml.jar Manifest.mf ml/*
The above steps should create a jar file ml.jar and can be executed with command java -jar ml.jar or write batch file that contains the command.
Correct if i'm wrong. -
JAR Files and Applets with Java Plug-In
This seems to be a basic question, but I can't figure it out! I have a jar file that contains all my class files for my applet. The jar file is in the same directory as the following html file:
<html>
<body>
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH = 700 HEIGHT = 510 codebase="http://java.sun.com/products/plugin/1.3.1/jinstall-131-win32.cab#Version=1,3,1,0">
<PARAM NAME = ARCHIVE VALUE = "myFiles.jar" >
<PARAM NAME = CODE VALUE = "MainView.class" >
<PARAM NAME="type" VALUE="application/x-java-applet;jpi-version=1.3.1">
<PARAM NAME="scriptable" VALUE="false">
</OBJECT>
</body>
</html>
I've checked the jar file, it's the same name. MainView.class is most certainly in the jar file - yet everytime I open the page up, I get the class not found error:
java.lang.ClassNotFoundException: java.io.FileNotFoundException
MainView.class (The system cannot find the file specified)
If I don't jar the files, the applet works fine - but I want to jar them as it's some 20 class files. What am I doing wrong?I've had a similar problem where it pops up the Java Extension Installation window, and starts downloading. Everything appears normal, but when it tries to run the applet it gets "load: class <className> not found" where <className> is the name of the class in my CODE parameter.
It appears that on occasion the download of the jar gets cut off. When I searched the browser's cache, I find a jar file that has fewer bytes than it should. In order to initiate a retry, you have to delete the jar file from your browser's cache, close all your browser windows so that the Plug-in with its truncated jar file stops running, and load the HTML page again. It appears that it checks the timestamp of the jar file in your cache and the one on the server and decides that it doesn't need to download it again. But if you delete it from your cache, it forces a retry.
I never have this problem when I open from my hard drive. I've never had the problem with a cable modem connection. I've had it once from a corporate LAN hitting an internet server (ie., outside corporate WAN). I've had people report the problem with dial-up connections. My theory is that whatever Sun is using to download the applet is more sensitive than either HTTP download or FTP.
Has anybody else experienced this problem? Is there anything you can do about it? I couldn't find a bug report on it. Is there one? -
JAR file and applets...
Hi all,
I have read almost all relevant posts, but it looks like there was no question like that one...
I am trying to create a jar file that contains all classes of my applet. The structure of the JAR is as followed:
chatApplet/gui/ChatApplet.class
the ChatApplet class is the class which extends java.awt.Applet class. Note that I work with AWT only.
in the HTML file I added the following:
<applet code="chatRoom.gui.ChatApplet" archive="chat.jar" width="300" height="200"></applet>
Now, why do I get the classNotFound exception? I know that if I will put the entry class outside the packages (i.e., next to the root of the package hierarchy) it would work just fine...
Am I missing something here?
Wating for your help!
David.gee... Do you know how it is that you say to yourself "I won't get up till I solve it...". I guess that when you are locked on something you simply HAVE to take a break... :o)
Thanks for opening my eyes... :o)
David. -
Accessing web application JAR files from applet
I've got an applet which is part of a web application.
All the web application JARs are in the webapps/myappl/WEB-INF/lib directory, and I
can't seem to place anything in that directory on the archive attribute of <OBJECT> tag.
I'm running into trouble because I'm sending objects from the servlet to the applet and keep getting classnot found during deserialization because I've missed some jar file on the archive attribute. I've had to copy lots of jar files up to where the codebase in the HTML file is to make this run. My question is this.
Is it better to just change the tomcat security policy file (catalina.policy in tomcat conf directory) so that the JARs are directly accessible and I don't have to copy them from WEB-INF/lib???? Has anyone done this before? What would the line look like?
I'm assuming that I have to follow the instructions (THAT I DON'T UNDERSTAND)
at the bottom of the policy file. Can someone help me out here????
should I have something like
grant codeBase "file:${catalina.home}/webapps/myappl/WEB-INF/classes/-"
{ permission java.security.AllPermission; };
grant codeBase "file:${catalina.home}/webapps/myappl/WEB-INF/lib/-"
{ permission java.security.AllPermission; };
Will this allow me to place references to jar files (and the classes directory) in the archive attribute, such as
<OBJECT ..... >
<param name="archive" value="../WEB-INF/lib/applet.jar,../WEB-INF/lib/someapp.jar,../WEB-INF/classes" />trailer for catalina.policy is
// You can assign additional permissions to particular web applications by
// adding additional "grant" entries here, based on the code base for that
// application, /WEB-INF/classes/, or /WEB-INF/lib/ jar files.
// Different permissions can be granted to JSP pages, classes loaded from
// the /WEB-INF/classes/ directory, all jar files in the /WEB-INF/lib/
// directory, or even to individual jar files in the /WEB-INF/lib/ directory.
// For instance, assume that the standard "examples" application
// included a JDBC driver that needed to establish a network connection to the
// corresponding database and used the scrape taglib to get the weather from
// the NOAA web server. You might create a "grant" entries like this:
// The permissions granted to the context root directory apply to JSP pages.
// grant codeBase "file:${catalina.home}/webapps/examples/-" {
// permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect";
// permission java.net.SocketPermission "*.noaa.gov:80", "connect";
// The permissions granted to the context WEB-INF/classes directory
// grant codeBase "file:${catalina.home}/webapps/examples/WEB-INF/classes/-" {
// The permission granted to your JDBC driver
// grant codeBase "file:${catalina.home}/webapps/examples/WEB-INF/lib/driver.jar" {
// permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect";
// The permission granted to the scrape taglib
// grant codeBase "file:${catalina.home}/webapps/examples/WEB-INF/lib/scrape.jar" {
// permission java.net.SocketPermission "*.noaa.gov:80", "connect";
// };Thank you for your reply.
As I mentioned in my first post I had seen a couple of posts mentioning ServletContext before, but dismissed them as I am not using any servlets of my own. However, since you showed me exactly how it was used I realised I could probably just use a dummy servlet to get this information.
The following page suggests a couple of techniques for doing just this.
http://www.jguru.com/forums/view.jsp?EID=1087411
So I think that's me sorted, cheers. -
Can i load a class in subdirectoy inside a jar file using applet tag?
hi every one.. thank you for reading ... i am really in dire need for the solution..
my problem is that i have a jar file contianing a package which inturn contains my applet class...
i am trying to access this applet class using a applet tag in html file. this html file is in same directory as the jar file. i am having no problems in windows but when i am doing this in linux apache server i was getting class not found exception. (already checked the file permissions). and when i am successful when using simple package directory instead of jar file . so gist of my quesition is "can i load a class in subdirectoy inside a jar file using applet tag in a html file"?When you tested in Windows were you using Internet Explorer? On Linux you will be using a different browser, usually Mozilla of some version, or Firefox. Note that the HTML tags for applets will be different between the browsers if you are using the object tag. Principally the classid value for the object tag will differ between Firefox and Internet Explorer.
-
Including multiple jar files to applet
In one of my application I am using severla third party apis (JavaHelp, JFreeReport, NanoXml ...) which comes as a seperate jar file each.
Is there is a way that I can include these multiple jar files to be downloaded automaticaly when the applet is starting.
currently I am extracting all the jar files and then re compressing them in to one file and place it in the archive property in the applet tab.
Is there a way I can avoid extraction and recompression and directly use the jar files<param nama="archive" value="myjar.jar, myOtherjar.jar" />
You could try to create an installer that wil put the 3rd party jars in the users lib/ext directory. -
My applet class is using other classes in my package,
So do i need to create a jar file and specify that jar file in <applet archieve = :myjar.jar"
I did created the jar file , but its not loading up, the browser just says Loading java applet, what might be the reason, does it depends on size of jar file?
or my tags are wrong.
my applet tag is
<html>
<applet archive = "myjar.jar"
code = "front.class"
width.. >
the front.class file is also in myjar.jar.
Any help....
Also one more question,
Can i call other applets within one applet class.
I have a gui, when a particular button is clicked on applet
i want to go to other applet, so how should i call it in that buttons action listner?
And in my applet class i am using one other class from my package which actually coonects to databse through JDBC. now say i have a button on my applet whihc says "Connect", and when that button is clicked then I created object of my other class which makes connection
through databse. So will this work from applet?
Thanksmy applet tag is
<html>
<applet archive = "myjar.jar"
code = "front.class"
width.. >Just to get you started - if it is a JApplet, not an Applet, then you need to use different HTML tags, otherwise it won't work. If you have JDK1.3, look in the /bin directory - you should see a file called "HTMLConverter.bat" if it's there, cd to the directory where your HTML file is, and type
"HTMLConverter wateverYourHTMLPageIsCalled.htm"
(case sensitive - and remember to check whether its called ".htm" or ".html")
When it has executed successfully, look at the source of your html - it should be different (<OBJECT> tags and lots of other stuff)
If you have an older version of the JDK, or don't have HTMLConverter.bat, you can download it from Sun's website.
Now you should be able to run your applet...
>
Can i call other applets within one applet class.
If you use "getAppletContext().showDocument(URL url)", this will replace the current html page with the new one - is that what you mean?
And in my applet class i am using one other class from my package which actually
coonects to databse through JDBC. now say i have a button on my applet
whihc says "Connect", and when that button is clicked then I created object
of my other class which makes connectionthrough databse.
So will this work from applet?Should do :-) -
Just starting a J2ME project.
An embarrassingly Noobie Question:
1) All the classes that are supposedly "built-in" to my device (phone)
do NOT need to be included in the deployed JAR file, right?
2) Anyone know how to do that in Netbeans 5.0?
Project -> Properties -> Build shows sources filtering
but that doesn't include anything from my "input"/library .JARS.
However, all the com.*, javax.* and java.* files are being included in
my output JAR file and it causes failures in preverify and loading
on the phone.
HELP!!hi,
any know this question
please send me the procedures about how load my J2ME
application(jad and jar file) into CDMA mobiles
like(Nokia 6255,6235,6235i etc..).
its very urgent for me,
please anybody known this answer reply very soon.
thanks a lot
laxmi.Hi
I am also having the same problem , any one has found solutions kindly inform. I want to install the spreadsheet viewer. Has any body developed solutions for the same - Please help
Thanks a lot
Ragupathi -
Jar files and Main-Class attribute
Sorry, I know there are other topics regarding this argument but none of them helped me solving my problem.
I've tried a thousand time in every possible way, but I still can't run my application from a jar file. I've got a package called client, whose main class is called Client. The package contains a sub-package called Icons. I've put everything into a jar file and added this manifest:
Manifest version: 1.0
Name: client/
Sealed: True
Main-Class: client.Client
But it won't work. I've tried to erase the Sealed part, I've tried "Main-Class: Client" and also "client/Client", I've tried putting into the jar the client directory and I've tried omitting it, but the answer is always the same:
Failed to load main-class header etc.
Can anyone help me? Please, I'm almost desperate!
ThanksHere's the verbose-mode description of what I did.
jar -cfv client.jar clientaggiunto manifesto
aggiunta in corso di: client/(in = 0) (out= 0)(archiviato 0%)
aggiunta in corso di: client/.nbattrs(in = 767) (out= 310)(compresso 59%)
aggiunta in corso di: client/Client.class(in = 533) (out= 340)(compresso 36%)
aggiunta in corso di: client/Client.java(in = 288) (out= 140)(compresso 51%)
aggiunta in corso di: client/ClientForm$1.class(in = 691) (out= 383)(compresso 44%)
aggiunta in corso di: client/ClientForm$10.class(in = 678) (out= 380)(compresso 43%)
aggiunta in corso di: client/ClientForm$11.class(in = 689) (out= 385)(compresso 44%)
aggiunta in corso di: client/ClientForm$2.class(in = 686) (out= 379)(compresso 44%)
aggiunta in corso di: client/ClientForm$3.class(in = 686) (out= 381)(compresso 44%)
aggiunta in corso di: client/ClientForm$4.class(in = 686) (out= 380)(compresso 44%)
aggiunta in corso di: client/ClientForm$5.class(in = 686) (out= 383)(compresso 44%)
aggiunta in corso di: client/ClientForm$6.class(in = 718) (out= 399)(compresso 44%)
aggiunta in corso di: client/ClientForm$7.class(in = 718) (out= 400)(compresso 44%)
aggiunta in corso di: client/ClientForm$8.class(in = 718) (out= 399)(compresso 44%)
aggiunta in corso di: client/ClientForm$9.class(in = 718) (out= 398)(compresso 44%)
aggiunta in corso di: client/ClientForm.class(in = 33070) (out= 13510)(compresso 59%)
aggiunta in corso di: client/ClientForm.form(in = 131398) (out= 4521)(compresso96%)
aggiunta in corso di: client/ClientForm.java(in = 73435) (out= 6863)(compresso 90%)
aggiunta in corso di: client/Icons/(in = 0) (out= 0)(archiviato 0%)
aggiunta in corso di: client/Icons/brick.gif(in = 1044) (out= 1049)(compresso 0%)
aggiunta in corso di: client/Icons/corpo.gif(in = 4011) (out= 3400)(compresso 15%)
aggiunta in corso di: client/Icons/door.gif(in = 1092) (out= 1097)(compresso 0%)
aggiunta in corso di: client/Icons/floor.gif(in = 1102) (out= 1107)(compresso 0%)
aggiunta in corso di: client/Icons/mappa.gif(in = 20901) (out= 20575)(compresso 1%)
aggiunta in corso di: client/Icons/paesaggio.gif(in = 18962) (out= 18603)(compresso 1%)
aggiunta in corso di: client/Icons/sole.gif(in = 7063) (out= 6546)(compresso 7%)
aggiunta in corso di: client/Icons/trap.gif(in = 1062) (out= 1067)(compresso 0%)
aggiunta in corso di: client/Icons/void.gif(in = 842) (out= 847)(compresso 0%)
aggiunta in corso di: client/Listener.class(in = 1869) (out= 1136)(compresso 39%)
aggiunta in corso di: client/Listener.java(in = 2296) (out= 708)(compresso 69%)
aggiunta in corso di: client/manifesto.txt(in = 62) (out= 58)(compresso 6%)
aggiunta in corso di: client/ScorciatoieDialog$1.class(in = 740) (out= 391)(compresso 47%)
aggiunta in corso di: client/ScorciatoieDialog$PopupListener.class(in = 1579) (out= 773)(compresso 51%)
aggiunta in corso di: client/ScorciatoieDialog.class(in = 3524) (out= 1638)(compresso 53%)
aggiunta in corso di: client/ScorciatoieDialog.form(in = 8500) (out= 910)(compresso 89%)
aggiunta in corso di: client/ScorciatoieDialog.java(in = 5676) (out= 1222)(compresso 78%)
jar umf mainclass.txt client.jar[NOTE: mainclass.txt only contains the line "Main-Class: client.Client"]
java -jar client.jarFailed to load Main-Class manifest attribute from
client.jar
I've also tried to manually create a MANIFEST.MF file that only contained the following lines:
Manifest Version: 1.0
Main-Class: client.Client
guess what was the result?
java -jar client.jarException in thread "main" java.io.IOException: invalid manifest format
at java.util.jar.Manifest.read(Manifest.java:193)
at java.util.jar.Manifest.<init>(Manifest.java:52)
at java.util.jar.JarFile.getManifest(JarFile.java:158)
>
the same procedure with the addition of "Name: client/" before the main-class attribute generated the usual "Failed to load Main-Class manifest attribute" result. So now what?!? I'm getting crazy.... -
Encryption/decryption through jar file and classes
Hi,
My application uses tomcat as web server.
I am doing encrytion and decyption.
i fetch encypted data from database and then decrypt it
If i use calsses in webapps -> WEB-INF -> classes folder, i place classes in that ,
In other case i use jar file and place that file in WEB-INF -> lib folder in the webapps directory.
There is huge performance difference.
While using classes performance is great while using jar file performance is very disappointed.
I am using a file for encryption /decryption also.Are you getting any error messages? Have you put debugging code in those classes to see what is happening?
-
How to Add JAR files and Config files to CLASSPATH at runtime?
QUERY:
During runtime, I need to load the JAR files and relevant config files( .cfg files and .properties file) into CLASSPATH and run a specific java program from one of the JAR which is available in CLASSPATH.
Please advise me any relevant Java API details or a sample java program to implement the above use case.
Thanks in advance.During runtime, I need to load the JAR files and relevant config files( .cfg files and .properties file) into CLASSPATH and run a specific java program from one of the JAR which is available in CLASSPATH.
Please advise me any relevant Java API details or a sample java program to implement the above use case.
You don't add to YOUR classpath once your app is launched.
You create a NEW process for the app you want to run and provide the proper environment for it to run in - including any PATH or CLASSPATH environment variables.
The Java API for the ProcessBuilder class has a simple example that shows how to create the arguments and launch an external application.
ProcessBuilder (Java Platform SE 7 )
There are also PLENTY of other examples of using ProcessBuilder; just search the net. -
To add the JNI dll to the jar file and use the dll inside the jar file
Hi to everybody,
I am new to java.
I want to add the JNI dll to the jar file and use it in the java class.
How can I achieve it.
Please help me.
Thanks in advance.
Regards,
M.Sivadhas.can't be done because none of the known operating systems support reading binary libraries from .jar files ... you can add the binary to the jar but then you have to extract it...
besides, mixing platform specific and platfrom independent components is not a very good idea, i'd keep the dll out of the jar to begin with -
Decompiling jar file and then run
Dear Members,
I have a jar file and I have decompiled that jar file and converted into class file,
now I want to run/edit using source code ,I am unable to run source code with out put whatever coming in jar file running,
I am trying with class in which
public static void main(String[] args)
function defined,
I am using Jcreater1.5 and from command prompt also running but unable to run and edit the programm,
how to run these class file in complete project that output will come as running jar file
regards
SACHINIt sounds like you have unpacked the jar.
To edit the source you need to decompile the classes to .java files.
[http://www.google.co.uk/search?q=java+decompiler]
Maybe you are looking for
-
When my kids got iPods several yrs ago I set up an Apple ID. When I later got an iPhone I used the same ID. Now they have iPhones. I understand it's best for them to have their own Apple ID. Can they initially connect using my Apple ID to retriev
-
I can't get rid of white space between images (even when margins are 0)
I'd like the user to be able to add two images that actually touch. I've set up 2 image fields that are touching, and set the margins to 0, but there is still white space in between the user added pictures. I thought maybe the problem had something t
-
Since i updated 6.1.3 phone is not connecting to wifi?? Help
since i updated 6.1.3 phone is not connecting to wifi?? Help
-
HI, I would like to start a small training institute in a small town in maharashtra ,India, I learnt from the web site that I can use the Oracle 10g express edition. Is that free ? What are the features I can use in this edition for coaching.
-
Outlook controls in custom form region created in Visual Stdio 2010
Hi, Is it possible to use all the outlook controls (e.g. Body control, Send button) in custom form region created in Visual studio. Thanks & Regards, Vijay