Who to create a JAR file with JSF pages ?
Hi,
I'm facing the problem of using a component that has classes and JSP files (just think in a security component, or a CRUD component, etc). So far you need to copy the jar with the classes and each JSP, each one to its directory together with other dependencies.
What are you using to package JSF's and classes ? Are you aware of some solution today for this?
Thanks in advance,
Juan
Sun's App Server allows you to precompile JSPs so you don't need the .jsp files for deployment. In the past I've also servled up precompiled JSP's from a Servlet (when the server required the .jsp file there otherwise).
For JSF, JSFTemplating allows the pages to be stored in a .jar flie directly and doesn't require any compiling. So this is very simple... this is what GlassFish is using.
I hope this helps!
Ken Paulsen
https://jsftemplating.dev.java.net
Similar Messages
-
How do you create a jar file with txt and classes?
Hey, I'm trying to create code to create a jar file with a text file, but I can't figure out how to add the text file. Here is what I have so far:
try {
// Name of jar file to write
String archiveFile = "test.jar";
Manifest jman = new Manifest();
try {
// Create a manifest from a file
//InputStream fis = new FileInputStream("manifestfile");
//Manifest manifest = new Manifest(fis);
// Construct a string version of a manifest
StringBuffer sbuf = new StringBuffer();
sbuf.append("Manifest-Version: 1.0\n");
sbuf.append("Ant-Version: Apache Ant 1.7.1\n");
sbuf.append("Created-By: 1.5.0_19-137 (Apple Inc.)\n");
sbuf.append("Main-Class: Main\n");
sbuf.append("Class-Path: lib/swing-layout-1.0.3.jar\n");
sbuf.append("X-COMMENT: Main-Class will be added automatically by build\n");
// Convert the string to a input stream
InputStream is = new ByteArrayInputStream(sbuf.toString().getBytes("UTF-8"));
// Create the manifest
jman = new Manifest(is);
} catch (IOException e) {
FileOutputStream stream = new FileOutputStream(archiveFile, true);// archive file is jar file name
JarOutputStream out = new JarOutputStream(stream, jman);
out.putNextEntry(new JarEntry("test.txt"));
out.closeEntry();
out.close();
} catch (Exception ex) {
}It creates the .jar file with the correct manifest but I can't get it to write the test.txt or anything else into the jar file.
-Gandolf
Edited by: GanMatt on Jun 18, 2009 8:18 AM
Edited by: GanMatt on Jun 18, 2009 8:19 AMAlright, my question has changed. Here's the code:
try {
// Name of jar file to write
String archiveFile = "test.jar";
Manifest jman = new Manifest();
try {
// Create a manifest from a file
//InputStream fis = new FileInputStream("manifestfile");
//Manifest manifest = new Manifest(fis);
// Construct a string version of a manifest
StringBuffer sbuf = new StringBuffer();
sbuf.append("Manifest-Version: 1.0\n");
sbuf.append("Ant-Version: Apache Ant 1.7.1\n");
sbuf.append("Created-By: 1.5.0_19-137 (Apple Inc.)\n");
sbuf.append("Main-Class: Main\n");
sbuf.append("Class-Path: lib/swing-layout-1.0.3.jar\n");
sbuf.append("X-COMMENT: Main-Class will be added automatically by build\n");
// Convert the string to a input stream
InputStream is = new ByteArrayInputStream(sbuf.toString().getBytes("UTF-8"));
// Create the manifest
jman = new Manifest(is);
} catch (IOException e) {
FileOutputStream stream = new FileOutputStream(archiveFile, true);// archive file is jar file name
JarOutputStream out = new JarOutputStream(stream, jman);
out.putNextEntry(new JarEntry("test.txt"));
out.write("Hi".getBytes());
out.flush();
out.closeEntry();
out.close();
} catch (Exception ex) {
JOptionPane.showMessageDialog(this,ex.toString(),"BUG!",JOptionPane.INFORMATION_MESSAGE);
}It creates the jar file with the txt file inside it, but I can't write "Hi" inside of the text file. Any ideas?
-Gandolf -
Problems creating a jar file with eclipse
"posted as well on the eclipse forum but who knows maybe some of you had same issue before"
Hi Developers.
My issue is this, i have some java files which i would like to export and use as .jar files.
All files contains classes, the files all ends with .java extention and are contained into a java project.
I've seen the Eclipse tutorial for this case which advise to use:
Click on project>Export>java>jar file>Save as("verkiezingen")>Location("desktop")
Indeed it seems successfull as i see on my desktop the .jar file and while exporting the final dialog box does not tell me "exported with warnings"
I then try to import the jar within a project like so:
Right click on project>Build Path> add external jar's>select jar
all good so far as i see the new item "Referenced package" under the usual "JRE system library"
If now, within the project i create a new class and start with import.verkiezingen;
it gives me an error message saying "The import verkiezingen cannot be resolved"
cant understand why, if i open the jar from the "Reference package" the classes are there.
I will paste the code of a class within the project i've tried to export initially as jar.
code:
public class StemmachineException extends RuntimeException {
public StemmachineException(){
super();
public StemmachineException(String s){
super(s);
code:
Thank you guysdoes the class have a package 'verkiezingen'? I don't see the package statement in your source listing.
For that matter, is the class in a subdirectory 'verkiezingen' inside the jar?
btw 1: use code tags when posting code to prevent the forum from swallowing certain characters, and to make it far more readable
btw 2: boooooo to non-English class names :( I hope you don't get coworkers that don't speak Dutch. -
Create a complete jar file with jscreator
Please provide all details for creating a jar file with jscreator for this 77 year old puzzle creator
Hi,
I would suggest switching to NetBeans IDE. It allows for the following:
- Ability to run with latest JDK release
- Enabled with the latest Java technologies
- Support for a greater number of application servers
The following will help with migration (if you already have a project setup in Creator)
http://www.netbeans.org/kb/60/web/creator-migration.html
Also, the following article describes how to create and Distribute Executable JAR Files in NetBeans
http://www.netbeans.org/kb/articles/javase-deploy.html
NetBeans website for downloads and other information;
http://www.netbeans.org/index.html -
I have a package called voiceexpert which contains three classes: Disease, DiagnosingEngine and Symptoms which is a JavaBean. Symptoms makes use of Disease and DiagnosingEngine objects.
voiceexpert is stored in the directory: c:\diagapp3
I compiled Symptoms.java as below:
c:\diagapp3> javac -d . Symptoms.java
The class files for Disease.java, DiagnosingEngine.java and Symptoms.java are placed in the directory: voiceexpert.
I created a Manifest.txt file inside c:\diagapp3 containing the following:
Main-Class:voiceexpert.voiceexpert.Symptoms
Name:voiceexpert/Symptoms.class
Java-Bean:True
I later created the jar file with the command:
jar cfm jjj.jar Manifest.txt voiceexpert\*.*
But, I am having the error message: "*invalid header field*".
What can I do to remove this error?
Note: I created the Manifest.txt using utf-8 encoding. My code is to be used in a third-party application and that is why it does not contain a main method.
The link I was referred to could not help me. I need help please!
Edited by: Adeyi on Feb 24, 2010 2:26 AM
Edited by: Adeyi on Feb 24, 2010 2:34 AMAdeyi wrote:
..I created a Manifest.txt file inside c:\diagapp3 containing the following:
Main-Class:voiceexpert.voiceexpert.Symptoms
Note: I created the Manifest.txt using utf-8 encoding. My code is to be used in a third-party application and that is why it does not contain a main method.Why are you specifying a main-class when the API has none?
The link I was referred to..What link? Just imagine for the moment that the Internet is a big place and we are not psychic. -
Ejbc - creating deployable jar file
Hi ...
I have created the home/remote interface and the bean...I deployed them thru the Webogic 5 GUI and its working fine.
I try to do it from the console ...i create 2 xml files ..keep it in the meta-inf folder...create a jar file with C:>jar cvf ..... command..
When i try to create a deployable jar file with C:> ejbc command it gives the folloing error
"ERROR: Error from ejbc: Unable to load a class required by your EJB: hello.HelloHome
ERROR: ejbc found errors"
My ejb-jar.xml file is as follows ->
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>Hello</ejb-name>
<home>hello.HelloHome</home>
<remote>hello.Hello</remote>
<ejb-class>hello.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>
Also if I remove the package and then try to create the deployable jar file it works perfectly fine...
Any idea..why's the problem coming...
Replies awaited!
Thanks in advance...set classpath for j2ee.jar, jar files that comes with weblogic 5.1
then try it out.. -
Hello, I am creating a simple JAR file containing a group of Java classes. It is not an executable JAR file and is simply a way for me to zip up a bunch of classes I want to use in another project. The problem is, after I create it in RAD using the JAR File Export and drop it into WEB-INF/lib in my other project, it shows as a text file in my Java perspective and I can't see any of the classes.
Is there something else I need to do with my classpath or anything like that? I recently put the Jakarta Commons JAR in the same folder and after a refresh, it showed ready to go. What am I missing here?Rational Application Developer, IBM's IDE. It has a
Create JAR file utility which supposedly makes it
easy. I'd like to use this if I can because there
are a ton of files. I just don't know what I'm doing
wrong after I create it.Not many people here can help with a question related specifically to an IDE. I had a problem in the past when I tried to create a JAR file with Eclipse. After trying to create the JAR file using the command line utility, I was able to better figure out my error. I strongly recommend you do the same, and post any error message(s) you receive here. -
How to run jar file with classpath?
Hi, all,
I have some package in my project, with which I have a java help jar file as classpath, when I run my project, I need the jh.jar file in directory /jar/jh.jar.
Now, I bundled all my class packages into a jar file, my.jar, together with the /jar directory. When i run my jar file with command:
java -jar my.jar
It tells me couldn't find javahelp class.
What shall I do? How can I create my jar file with the jh.jar?
Thanks in advance.Thanks, hjembaek,
But it doesn't work for me. I am running in windows, it still generate the error:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/help/HelpSet
at own.gui.OwnMenuToolBar.getOwnHelpBroker(OwnMenuToolBar.java:560)
at own.gui.OwnMenuToolBar.addHelpMenu(OwnMenuToolBar.java:327)
at own.gui.OwnMenuToolBar.getOwnMenuBar(OwnMenuToolBar.java:188)
at own.gui.OWNDPTool.initGui(OWNDPTool.java:55)
at own.gui.OWNDPTool.<init>(OWNDPTool.java:39)
at own.gui.OWNDPTool.main(OWNDPTool.java:100)
Here is my command to generate the jar file:
jar cfm Own.jar temp.txt help own log others
temp.txt is the file including the main class and class path information
I have help folder, log folder and own package, others is directory that has the jar file(others/jh.jar) -
Signing a jar file with a java program
Hello folks,
It's easy to create a jar file with a java programm, but can I sign it as well with pure java code or do you have to invoke jarsigner?
Regards
Der HinterwaeldlerWell J2SE 1.x supports ZipOutputStream (jar's are zips with a META-INF/MANIFEST.MF file) and www.bouncycastle.org has API's for signing etc.
So in theory you could take a directory or an existing jar and make a jar and sign it.
The only question is the format on how to sign them properly. I wouldn't be suprised if someone already wrote an API for this format. For example BouncyCastle supports S/MIME and PGP, but I don't know what is the format for jars. -
Jar files with digital signature -pl help
Hi there
is there anybody who will help me guiding step by step how to create a jar file (executable) with digital signature?
thanks in advance.Sorry, digital signatures have nothing to do with decompilation security. The short answer is, there's nothing you can do about it. Search the forum for 'obfuscator', a lot of people have asked the same question.
-Ron -
App runs in Eclipse environment but not from jar file with no error message
When I upgraded my jre to 5.0 my app does not run. After fixing the properties problem I had a few days ago it is now at least compiling and running within Eclpse
However, when I export to a jar file it runs to a certain point and then just goes away with no error message!!! I've narrowed it down to the exact point where it dies but don't understand why it dies and especially gives me no errors whatsoever. It just goes away.
It is creating an instance of a new class when it dies.
Can someone please help me?Ok, well it doesn't. Anyway, I'm still having the same problems. I can run my jar file to a certain point and then the application just stops. I know this because I've put come message boxes in the application to let me know where in the app the system is.
It always dies when it is instantiating the new class called HeidiFrame; done by:
HeidiFrame heidiFrame = null;
if I put code in between the above line and before the below line, this code will work fine
heidiFrame = new HeidiFrame();
but if I put code after the above line, nothing happens
As I said this all worked fine until I upgraded to Java 1.5
If you look at http://java.sun.com/javase/technologies/compatibility.jsp there are 23 compatibility issues with the new release. We're using xml stuff so that was my first problem and the code wouldn't even compiile. Once I added in libraries, the code compiled and ran beautifully.
However, when creating my jar file so I can deploy this application , I've discovered that the jar file will only run to a certain point, as I've stated previously. So, that's my problem. Not that I can't run it from the command prompt, which I can't, but it's a gui application. I've tried changing things in the classpath file and the manifest to no avail. Nothing changes. The application starts but when it goes to instantiate the HeidiFrame class, which is the class that actually builds the gui it dies and goes bye bye. -
How can I get a single jar file with NetBeans?
How can I get a single jar file with NetBeans?
When I create the project I get these files:
dist/lib/libreria1.jar
dist/lib/libreria2.jar
dist/software.jar
The libraries that have been imported to create the project are in separate folders:
libreria1/libreria1.jar
libreria2/libreria2.jar
libreria1, libreria2, dist folders are all located inside the project folder.
I added the following code to the build.xml:
<target name="-post-jar">
<jar jarfile="dist/software.jar">
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
<zipfileset src="dist/lib/libreria1.jar" excludes="META-INF/*" />
<zipfileset src="dist/lib/libreria2.jar" excludes="META-INF/*" />
<manifest>
<attribute name="Main-Class" value="pacco.classeprincipale"/>
</manifest>
</jar>
</target>
Of course there is also the project folder:
src/pacco/classeprincipale.form
src/pacco/classeprincipale.java
Can you tell me what is wrong? The error message I get is as follows:
C:...\build.xml:75: Problem creating jar: archive is not a ZIP archive BUILD FAILED (total time: 2 seconds)This is not a NetBeans forum, it is a JDeveloper forum. You might want to try http://forums.netbeans.org/. I also saw your other question - try looking in the New to Java forum: New To Java
-
Exception while creating a jar file for bean
Friendz,
I am getting this error whenever i tried to create a jar file.
I am using win 98 os and jdk1.4 please tell me what error it is
C:\bean\programs\spectrum>jar cfm a.jar manifest.mft spectrum.class
java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Attributes.java:355)
at java.util.jar.Manifest.read(Manifest.java:162)
at java.util.jar.Manifest.<init>(Manifest.java:52)
at sun.tools.jar.Main.run(Main.java:124)
at sun.tools.jar.Main.main(Main.java:904)
Contents of manifest template file:
Name:spectrum.class
Java-Bean:TrueManifests are saved with the .mf file extension. Rename your manifest mainfest.mf.
-
How can I create a jar file that will run automatically on double click
all the jars I created run only from the command-line.
how can I make it run by double-click on it?First you will need to associate .jar files with the javaw.exe program in order to just be able to double click on the jar and run it from within a windows explorer application. Next you will need to set the main class attribute of the manifest file. My understanding is that the value of this attribute is used by the launcher to know which class to load. In other words, which is your main application class. To specify this attribute open your manifest file in a text editor. You will find this file located within the jar at META-INF/MANIFEST.MF. Then, add the line,
"Main-Class:<relative path to the main class>" However, remember not to add the .class extension to the end of the class name.
In Windows 2000 you can associate jar files with javaw by finding a jar file in Windows Explorer and right clicking it. This will give you a context menu which should have an Open With... option (if you are not using Windows 2000 and don't see the 'open with' menu item, try holding down the shift button while right click on the file). Select the Open With... option, then, when the dialog appears highlight javaw and select the "Always use this program to open these files" checkbox. When you hit the OK button you should have all your jar files associated with the javaw process.
Once you've done this, you should be able to double click on your jar file and run your application.
Regards,
Daniel Walsh -
Create a jar file using the jar tool
Hello all,
can somebody help me with this situation:
I use the following comand
jar cfm Seti.jar manifest.mf SetiSeti.jar is the name of the file I want to create and Seti is the name of the folder where I have the class files, the manifest file and the Seti.java. The manifest file is also out of this folder (exactly the folder were I use the command on the command line).
After creating the jar... I try to run it but it gives an error message: "can't find the main class..."
The content of the manifest file is:
"Manifest-Version: 1.0
Main-Class: Seti
I'd never created a jar file before and have already read all the usefull information here and at sun... I'm very preoccupied with this..
Can you help?
ThanksRuiAranhaJava wrote:
How do I do this?
"And you have to name that package as well when you name the main class in the manifest. "
But, as I have told the name of the package is SetiNo, you just told us that the name of your class is Set. You never told us about the name of the package.
Simples question possible: Does your class look something like this:
package Seti;
// maybe there are some import statements here, maybe not
public class Seti {
// maybe there's something here, maybe not
public static void main(String[] args) {
// anything
}If so, then the fully qualified name of your class is "Seti.Seti" and you need to write that into the Main-Class attribute. (*)
If there is no package-Statement, then the fully qualified name of your class is simply "Seti" and the Main-Class attribute is correct, but your classes are in the wrong place.
Edit:
(*) Please note that package names should generally be all-lowercase, so it should be "seti" instead of "Seti". This helps distinguish it from the simple names of classes, so it's easy to see what you are talking about at a glance: "seti" would be the package, "Seti" the class name.
Maybe you are looking for
-
The function key in my Satellite C660 is not working
The function key in my Toshiba Satellite C660 is not working except for volume. That problem appeared after i changed something in the startup programs and uninstalling as i remember tvap and no button support appears in my start up programs :(
-
Exception (colouring cells) in report output based on formula.
Hi Gurus, I want to colour my cells in report output. But this coloring is not so simple. It has to be done based on a formula. Lets say i have material in rows and sales value by period in columns. .......................Jan'08......Feb'08.......Mar
-
i tried to install the latest update on my ipad. i get an image which says I tunes with a cord to plug in. it is on a black background.. it has been like this for three hours now. if i turn it off and then on again that is the only page that appears.
-
After software update, I can see the songs on iPod nano in iTunes, but I cannot play/move the songs from iTunes.
-
Hi, everyone, how to print two smartforms one after one?
first, merry christmas to you all. the question is that I want to call two smartforms sf1 and sf2, how to use one print program(I use print program to call them) or some other ways to call sf1 and after call sf1 I need to call sf2, finally they are p