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?
Similar Messages
-
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?
ThanksYou 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. -
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 file only works with 'java -jar'
I have a .jar file that contains an installer. When I double click it nothing happens on my work computer (vista32). I have tried moving it to my home computer (vista64 and winXP) there it works fine when I double-click it.
I have found a temporary solution for the work/vista32 machine. If I run it with:
java -jar installer.jar
it works. I have put this in the target of a shortcut to the file. But why do I need to do that manually when it works fine on my other machine by just double clicking the file?fedevaps wrote:
Thing is that if I move this jar to another machine it works fine! The thing is that you are missing the point.
It has nothing to do with the jar. Nor really java.
Double clicking works because the OS (windows not java) understands what to do when you double click.
If the OS (windows not java and definitely not the jar) does not understand then it doesn't work.
So there are two independent parts.
1. Create an executable jar.
2. Create the correct association in windows.
If you use the command line then you can absolutely verify that the first works. If it works then it means, absolutely (no other possibility) that if double clicking fails then the association, not the jar, is wrong.
If it doesn't work then it means absolutely (no other possibility) that the jar, not the association, is wrong. -
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. -
Jar file and source code? (new to java!)
Hi all!
Sorry if this is a dumb question but I'm really new to java (.net guy).
Someone sent me a jar file and now I need access to source code. I now that I can rename to .zip and view its contents (.class)...
But what about source code? Can I decompile? As i understand, .class files are compiled .java files...
Should I ask for the source code to the guys that sent me the .jar file?
thanks
jayHumm... is java as fast as replies in this forum? Thank's for your replies warnerja and zadok
I need the source code so that I can understand how the original developer solved a problem. I can ask for the source code.
I posted this message because I was afraid that the question was stupid and source code was in front of me. I am really new to java!
So. No source code in .jar or .class files. Right?
Thanks
Jay -
JAI extension automatic installation fail with Java Plug-in 1.4.1_01
Hi everyone,
i have a html page with an applet that use the JAI (Java Advanced imaging) extension. I used to run it with java plug-in 1.3.1_03.
When the JAI extension was not installed, it was automatically downloaded and installed. I use the sun "Signed Auto Installation for browsers" jar available on the JAI download page.
But with Java Plug-in 1.4.1_01, it seems to have a security problem. Is the "Signed Auto Installation for browsers" only java plug-in 1.3 compatible or is there a way to install it with 1.4.
If anyone has encountered the same problem with another extension, it could help me to know how to have it installed automatically with java Plug-in 1.4.
I tested on IE 4 and 6 on Windows NT4 & IE 6 on Windows 2000, and i have the same results.
Thanks
Philippe
see the following java console output :
Java(TM) Plug-in: Version 1.4.1_01
Using JRE version 1.4.1_01 Java HotSpot(TM) Client VM
Modality popped
User selected: 0
Optional package download granted by user, download from http://xxxxxxxxxxxxxxxxxxxxxx/jai_windows-i586.jar
Connecting http://xxxxxxxxxxxxxxxxxx/jai_windows-i586.jar with no proxy
Connecting http://xxxxxxxxxxxxxxxxxx/jai_windows-i586.jar with cookie "JIGSAW-SESSION-ID=J986902630-19"
Loading Root CA certificates from D:\PROGRA~1\Java\J2RE14~1.1_0\lib\security\cacerts
Loaded Root CA certificates from D:\PROGRA~1\Java\J2RE14~1.1_0\lib\security\cacerts
Loading JPI certificates from D:\WINNT\Profiles\qpbl\.java\jpicerts141_01
Loaded JPI certificates from D:\WINNT\Profiles\qpbl\.java\jpicerts141_01
Loading certificates from JPI session certificate store
Loaded certificates from JPI session certificate store
Checking if certificate is in JPI permanent certificate store
Checking if certificate is in JPI session certificate store
Checking if certificate is in Root CA certificate store
Checking if certificate is in Root CA certificate store
Checking if certificate is in Root CA certificate store
sun.misc.ExtensionInstallationException: User deny optional package installer to be launched.
at sun.plugin.extension.ExtensionInstallationImpl.verifyJar(Unknown Source)
at sun.plugin.extension.ExtensionInstallationImpl.access$100(Unknown Source)
at sun.plugin.extension.ExtensionInstallationImpl$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.extension.ExtensionInstallationImpl.installExtension(Unknown Source)
at sun.misc.ExtensionDependency.installExtension(Unknown Source)
at sun.misc.ExtensionDependency.checkExtension(Unknown Source)
at sun.misc.ExtensionDependency.checkExtensions(Unknown Source)
at sun.misc.ExtensionDependency.checkExtensionsDependencies(Unknown Source)
at sun.misc.URLClassPath$JarLoader.parseExtensionsDependencies(Unknown Source)
at sun.misc.URLClassPath$JarLoader.getClassPath(Unknown Source)
at sun.misc.URLClassPath.getLoader(Unknown Source)
at sun.misc.URLClassPath.getResource(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at sun.plugin.security.PluginClassLoader.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)
Modality pushed
Modality popped
Optional package installation failed.
Installation successfulI seem to be having the same problem. If you figured out the solution, can you please post it?
Thanks -
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 :-) -
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.... -
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. -
Use Forms with webutil with java plug
I am using oracle 9i forms with webutil, it works with jinitiator but I have problem runiing with java plug-in. I have changed formweb.cfg as follow. It des not work.
It works on oracle 10g rel1 appserver using jinitiator but does not work with java plug.
jpi_classid=clsid:8AD9C840-044E-11D1-B3E9-00805F499D93
jpi_codebase=http://java.sun.com/products/plugin/autodl/jinstall-1_4_2-windows-i586.cab#Version=1,4,2,0
jpi_mimetype=application/x-java-applet;jpi-version=1.4.2
webUtilArchive=/forms90/webutil/webutil.jar,/forms90/webutil/jacob.jar
baseHTMLJInitiator=basejpi.htmsee
Webutil using JAVA plug
Good thing to start using JRE anyway ;-)
Erwin -
A simple Java program to be compiled with ojc and executed with java.exe
Hi ,
This thread is relevant to Oracle Java Compiler (file ojc) and jave.exe file.
I have written a simple java program which consists of two simple simple classes and using the JDev's 10.1.3.2 ojc and java files , i'm trying to execute it after the successful compilation....
The problem is that trying to run it... the error :
Exception in thread "main" java.lang.NoClassDefFoundError: EmployeeTest
appears.
How can i solve this problem...????
The program is as follows:
import java.util.*;
import corejava.*;
public class EmployeeTest
{ public static void main(String[] args)
{ Employee[] staff = new Employee[3];
staff[0] = new Employee("Harry Hacker", 35000,
new Day(1989,10,1));
staff[1] = new Employee("Carl Cracker", 75000,
new Day(1987,12,15));
staff[2] = new Employee("Tony Tester", 38000,
new Day(1990,3,15));
int i;
for (i = 0; i < 3; i++) staff.raiseSalary(5);
for (i = 0; i < 3; i++) staff[i].print();
class Employee
{ public Employee(String n, double s, Day d)
{ name = n;
salary = s;
hireDay = d;
public void print()
{ System.out.println(name + "...." + salary + "...."
+ hireYear());
public void raiseSalary(double byPercent)
{ salary *= 1 + byPercent / 100;
public int hireYear()
{ return hireDay.getYear();
private String name;
private double salary;
private Day hireDay;
For compilation... i use :
D:\ORACLE_UNZIPPED\JDeveloper_10.1.3.2\jdev\bin\ojc -classpath D:\E-Book\Java\Sun_Java_Book_I\Corejava EmployeeTest.java
For execution , i issue the command:
D:\ORACLE_UNZIPPED\JDeveloper_10.1.3.2\jdk\bin\java EmployeeTest
NOTE:I tried to use the jdk of Oracle database v.2 but the error :
Unable to initialize JVM appeared....
Thanks , a lot
SimonHi,
Thanks god....
I found a solution without using Jdev.....
C:\oracle_files\Java\Examples>SET CLASSPATH=.;D:\E-Book\Java\Sun_Java_Book_I\Corejava
C:\oracle_files\Java\Examples>D:\ORACLE_UNZIPPED\JDeveloper_10.1.3.2\jdk\bin\javac EmployeeTest.java
C:\oracle_files\Java\Examples>D:\ORACLE_UNZIPPED\JDeveloper_10.1.3.2\jdk\bin\java EmployeeTest
What does Ant has to do with this?Sorry, under the Ant tree a classpath label is found....I'm very new to Java and JDev...
You need to include the jar file that has the Day method in it inside project properties->libraries.I have not .jar file.. just some .java files under the corejava directory.... By the way , I have inserted the corejava directory to the project pressing the button Add Jar/Directory.... , but the problem insists..
Thanks , a lot
Simon -
Possible to create a JAR file from within a java app?
Is it possible to create a jar file from within a java application?
Can it be done more elegantly than by spawning-off another
process with the Runtime and exec() portions of the api?
Thanks
ScottThanks! I was mislead by the API notes for java.util.jar:
The JarOutputStream class is used to write the contents
of a JAR file to any output stream.
I was looking for a class or method to make jar files.
Seems this is it ;)
Thanks
Scott -
Jar file import problem with ADF application
Hi Everyone,
I am using Jdev 11g with integrated WLS. I have an ADF application and is trying to integrate JasperReport in it. I added the JasperReport JAR file in the project properties -> Libraries and Classpath, and checked it for "export" and "Deployed by Default'. I have my JasperReport codes in my managed bean
as follows
+public String cb1_action() {+
+try {+
+JasperDesign design = JRXmlLoader.load("C:/JDeveloper/mywork/ReentryApplication/ViewController/public_html/jasper/testReport.jrxml");+
+JasperReport report = JasperCompileManager.compileReport(design);+
+....+
+}+
+}+
I am able to compile the managed bean class successfully. However when I run the application, I got a stack of errors like this,
+[2009-10-08T11:31:59.910-04:00] [DefaultServer] [ERROR] [] [javax.enterprise.resource.webcontainer.jsf.application] [tid: [ACTIVE].ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: test123] [ecid: 0000IGollZuB5EirL4YBUA1AnVop00000L,0] [APP: ReentryApplication] java.lang.RuntimeException: net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:[[+
+C:\Documents and Settings\MISSP29\Application Data\JDeveloper\system11.1.1.1.33.54.07\DefaultDomain\testReport_1255015914097_607807.java:4: package net.sf.jasperreports.engine does not exist+
+import net.sf.jasperreports.engine.*;+
+....+
It appears that the JAR file is not picked up at the runtime correctly. I tried a simple Main class with the same codes and JAR file added, it works fine. Does anyone know what I am missing within the ADF application?
Any helps would be appreciated.
Thanks,
John
Edited by: john wang on Oct 8, 2009 9:24 AMTimo,
Thanks you for your prompt response.
1. I checked The following folder (I assume this is where it supposes to be). The JAR file is there.
C:\Documents and Settings\MISSP29\Application Data\JDeveloper\system11.1.1.1.33.54.07\o.j2ee\drs\ReentryApplication\ReentryApplication-ViewController-webapp\WEB-INF\lib
2. I did not do anything about deployment descriptor. Since I run my application within JDev integrated WLS, I did not do anything about deployment setting. Do I need do something with deployment descriptor if I want to import additional JAR files here? With my experience with 10g, to add a JAR file within JDev, all I need to do is to add it through project properties ->libraries.
3. I agree with your absolute path comment. This is a test of how JasperReport works with ADF application. I will work it out later.
Thanks,
-John
Maybe you are looking for
-
Now I have an HD TV I thought I'd try to output finished sequences back to the camera, to play on the TV via HDMI. But I can't get FCE (3.5.1) to write correctly to the camera, a Sony FX7E. Print to video just puts the colour bars and countdown onto
-
I need to install Word for Mac on my MacBook OS X Lion 10.7.4, but there are two problems: 1) Microsoft sells only Office, not the individual programs, and 2) I don't have enough memory to do so (2 GB). Any suggesions? I'm currently using Pages,
-
Can't detect Network Connection?
I'm using a wireless connection at the library, and as long as I connect through Firefox it works fine (Safari gets picky about it), but I have trouble with both Mail and iChat AV. Neither can detect the connection at all. I ran connection doctor, an
-
Layer Opacity percentage from Photoshop is different in After Effects
When importing a layered PS CS3 document into AE CS3 with layers set to different opacity, AE interprets the % differently. AE displays the % as a whole number but when you click on the field you can see the number goes to at least the thousandths. T
-
The DHCP Service failed to see a directory server for authorization error
Hi Experts, "The DHCP Service failed to see a directory server for authorization error" I have DHCP Server installed on the same server where Active directory is installed its a domain controller, when I see the event logs I saw the above error. Thi