Help with Jar file exception
I have been following the example of instruction at:
http://forum.java.sun.com/thread.jsp?forum=31&thread=332680
But I get an exception when I do the following.
D:\pro>jar umf mf.txt myjar.class
java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Attributes.java:359)
at java.util.jar.Manifest.read(Manifest.java:162)
at java.util.jar.Manifest.<init>(Manifest.java:52)
at sun.tools.jar.Main.update(Main.java:487)
at sun.tools.jar.Main.run(Main.java:167)
at sun.tools.jar.Main.main(Main.java:904)Can somebody help me on this?
Thanks I will really appreciate.
I cannot execute the file, after I created, and then I add the mf intothe class, I double clicked but doesn't do anything.
Should I run it with the java -jar myjar.jar?
When I do it it throws me the following:
D:\z>jar cf myjar.jar myjar.class
D:\z>jar umf mf.txt myjar.class
D:\z>java -jar myjar.jar
Failed to load Main-Class manifest attribute from
myjar.jar
D:\chris\1\z>help please.
Similar Messages
-
I have a jar file named Helper.jar with
com.xyz.util.Helper.class in it.
Now I have a SrcFile.java that
imports com.xyz.util.Helper;
It compiles fine with:
java -classpath Helper.jar;. SrcFile.java
...and runs fine with:
java -cp Helper.jar;. SrcFile
When I jar it with:
jar cvfm SrcFile.jar SrcFile.mf *.class
...and run it with:
java -cp Helper.jar;. -jar SrcFile.jar
I get the following exception:
java.lang.NoClassDefFoundError: com/xyz/util/Helper
...but yet, Helpler.jar runs fine with:
java -jar Helper.jar
Does anyone have any idea what I am doing wrong or
do I have to un-jar the Helper.jar file and
re-jar SrcFile.jar with all the .class files?I've replied to this same thread in the New To Java Technology fourm, see there for a suggestion.
-
I'm writing a program in VB that calls on a JAR file. It has been working great for weeks. Last night, I moved the JAR file to a new location on my machine, and it suddenly stopped working at all.
I know nothing about Java. Do I need to recompile the file? I tried moving the whole directory back to its original location but it didn't help.
Thanks in advance.Dude I'm telling you straight up, the program has a bug. The evidence is in the error message. Maybe the bug was not manifested before, but it was there.
Do you have access to the source? Do you know how to compile it? You should recompile it with the -g flag to include debug information. Then the error message will include a method name and line number for the offending portion of code. If you're not able to figure it out yourself, you could post that portion of code here for someone to comment on. -
Now what? Help with .jar files
Hey. I just finished a program. I want to share it with my friends or anyone else. I can create a .jar file but I have no idea what to do next. Is there an easy way to "publish" your programs (like create a .exe file?). Any help or ideas would be appreciated. Thanks, Merlot14
java -jar MyFile.jarwill work if you've set your manifest correctly. If you're distributing only to Windows users, you could include a shortcut, I believe. Similarly, for distribution to Linux/OS X users, you could include a shell script.
-
I have made an application that uses the javax.comm library for serial port drivers. It works perfectely but when I put all the .class in a .jar and start the application it starts properly with no errors but it doesn't see the com's of the computer.
I would apreciate if you could help me out
greetings
paulYou have to modify the source code of the javax.comm class files you are using.. the line contains "package javax.comm;" should be deleted. And then compile those modified files and put the compiled files to your jar file. Or you can create a folder "javax" and subfolder "comm" in that folder and put those original .class files into "javax/comm". After that, put that "javax" folder into your jar file.
-
I am writing an Application in Java using swing and all that good stuff but I am currently ready to do some beta testing to find any other errors.
The problems is I want it to be easy to use so I was just going to throw the classes ina jar file so they could just run the jar files.
For some reason I keep getting a cannot find main class error??
Here is the manifest file for the Jar file
Manifest-Version: 1.0
Created-By: 1.4.0_01 (Sun Microsystems Inc.)
Main-Class: VRPServer.class
VRPServer is the class that has the main in it.
if I go to the command line and run I get
E:\JAVA\VRP\Server>java -jar VRPServer.jar
Exception in thread "main" java.lang.NoClassDefFoundError: VRPServer/class
if I double click the jar I get a pop-up saying "Could not find the main class, program will exit."
I really don't understand Jar files all that well, I went through the tutorials but still can't see why this isn't working. Any help is appreciated. :)I think your problem is that you shouldn't add the '.class' to the name of your main class in your manifest; it should simply be the fully-qualified name of the class, for example:
Manifest-Version: 1.0
Created-By: 1.4.0_01 (Sun Microsystems Inc.)
Main-Class: mypackage1.mypacage2.MyClassHope this is all it takes.
Shaun -
OK, folks, I need some help here...
And I have researched on this prior to this post, but I still don't get it.
I have a simple application in Reminder.java file. When I compile it, I get Reminder.class and Reminder$ReminderThread.class, because I have an inner class.
I place those files in Reminder directory. I want to make an executable JAR file, so I made a manifest file outside the Reminder directory that contains these lines
Manifest-Version: 1.0
Main-Class: Reminder.Remindersince the Reminder.class is within the Reminder directory, I understood I had to have a prefix "Reminder."
In the command line, I type
jar cmf manifest Reminder.jar Reminder/Reminder.class Reminder/Reminder$ReminderThread.classAnd I do get a Reminder.jar file, but when I double-click on it, I get a popup saying "Could not find the main class. Program will exit!"
So, what am I doing wrong and how can I fix this? As I said, I have researched, but I can't understand what went wrong nor how to fix the problem.
Any help will be greatly appreciated.Never mind, I solved it, I was missing a carriage return in my manifest file. I feel so stupid now...
-
Okay,
I built a simple Hello World project with Swing and it worked. Now I've build my own program from scratch and get a "Cannot find the main class" error from the JRE. Below are the contents of the manafest file craeted by Sun Java Studio 8.
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.5.0_06-b05 (Sun Microsystems Inc.)
Main-Class: localPkg.mainForm
X-COMMENT: Main-Class will be added automatically by build
Also here is the source code for localPkg.mainForm
* mainForm.java
* Created on January 17, 2006, 9:32 AM
* @author rowen
package localPkg;
import java.beans.*;
public class mainForm extends javax.swing.JFrame {
/** Creates new form mainForm */
public mainForm() {
initComponents();
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
ctoF1 = new MyBeans.CtoF();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
numericField1 = new magicbeans.NumericField();
numericField2 = new magicbeans.NumericField();
ctoF1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
public void propertyChange(java.beans.PropertyChangeEvent evt) {
ctoF1PropertyChange(evt);
ctoF1PropertyChange1(evt);
getContentPane().setLayout(new java.awt.GridBagLayout());
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Farenheight");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.ipadx = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(20, 110, 0, 0);
getContentPane().add(jLabel1, gridBagConstraints);
jLabel2.setText("Celsius");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(11, 110, 0, 0);
getContentPane().add(jLabel2, gridBagConstraints);
numericField1.setText("farenheightField");
numericField1.setName("farenheightField");
numericField1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
public void propertyChange(java.beans.PropertyChangeEvent evt) {
numericField1PropertyChange(evt);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 4;
gridBagConstraints.ipadx = 119;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(6, 110, 0, 160);
getContentPane().add(numericField1, gridBagConstraints);
numericField2.setText("celsiusField");
numericField2.setName("celsiusField");
numericField2.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
public void propertyChange(java.beans.PropertyChangeEvent evt) {
numericField2PropertyChange(evt);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.ipadx = 99;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(6, 110, 191, 0);
getContentPane().add(numericField2, gridBagConstraints);
pack();
// </editor-fold>
private void numericField2PropertyChange(java.beans.PropertyChangeEvent evt) {
ctoF1.setC(numericField2.getValue());
private void numericField1PropertyChange(java.beans.PropertyChangeEvent evt) {
ctoF1.setF(numericField1.getValue());
private void ctoF1PropertyChange1(java.beans.PropertyChangeEvent evt) {
numericField2.setValue(ctoF1.getC());
private void ctoF1PropertyChange(java.beans.PropertyChangeEvent evt) {
numericField1.setValue(ctoF1.getF());
* @param args the command line arguments
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new mainForm().setVisible(true);
// Variables declaration - do not modify
private MyBeans.CtoF ctoF1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private magicbeans.NumericField numericField1;
private magicbeans.NumericField numericField2;
// End of variables declaration
Using Sun Java Studio Enterprise 8 (patch 1), on Windows XP (most recent patches)
Thanks in advance,
RoyR_Owen ,
One possible way of how to do it in JSE8 is:
1. Put all necessary lib jars to some place under src folder.
2. Add those jars into Compile-time libraries list (Project properties -> Libraries) for correct compilation
3. Switch to 'Files' JSE8 tab, open manifest.mf file (it's in projects root) and add your lib jars to it.
Syntax is:
Class-Path: relative URLs
That's it.
And Class-Path attribute description from JAR File Specification:
http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#Main%20Attributes:
�Class-Path:
The value of this attribute specifies the relative URLs of the extensions or
libraries that this application or extension needs.
URLs are separated by one or more spaces.
The application or extension class loader uses the value
of this attribute to construct its internal search path. �
Copy/paste from:
http://swforum.sun.com/jive/thread.jspa?forumID=122&threadID=60169 -
Help with jar files and running them
I have been trying to figure out how to run executable java files, now I have heard that a million and one people have asked this already. Though when I see the answer to these questions I am still quite confused, I would like to understand some things. First thing is how do you even save your java code as a jar file. Secondly, what is a jar file. Thirdly, I have seen many people talking about batch files, what are they? And finally, I have used many "wrappers" and I still cannot get it to work. Plz help
A quick google search gave me [url http://neptune.netcomp.monash.edu.au/JavaHelp/howto/jar.htm]this website about jars.
-
I am new with JAR files please help me
Hi Dear All,
I am new with JAR files, I know concept, but dont know how to careate JAR, and how do i use it?
Please help me.
ThanksThis tutorial covers that:
http://java.sun.com/docs/books/tutorial/deployment/jar/index.html -
Help using jar file!
Hello
I have created a jar file by using
jar cvmf Manifest.txt myjar.jar 1.class Mydirectory
In 1.java file :I have used
JEditorPane editor;
editor.setPage(getClass().getResource("/Mydirectory/default.htm"));
If I am only giving myjar.jar file to the client without Mydirectory then also it is working fine by showing default.htm in JeditorPane.
But my problem is I want to use
Runtime.getRuntime().exec("cmd /c start IEXPLORE"+targetstr) ;
targetstr will be the filename with path of the default.htm
If I am giving myjar.jar file with Mydirectory to the client it is working but I don't want to give Mydirectory to the client .
What should I do?
Is there any solution for this?
Using another jar file which will include mydirectory can solve this problem?
Is there any othe concept in java so that I wll be able to hide Mydirectory from client?
Please help.It seems like you could extract the .htm file from the jar, either with Runtime.exec or using the Jar API classes.
-
Can some help with CR2 files ,Ican`t see CR2 files in adobe bridge
can some help with CR2 files ,I can`t see CR2 files in adobe bridge when I open Adobe Photoshop cs5- help- about plugins- no camera raw plugins. When i go Edit- preference and click on camera raw shows message that Adobe camera raw plugin cannot be found
That's strage. Seems that the Camera Raw.8bi file has been moved to different location or has gone corrupt. By any chance did you try to move the camera raw plugin to a custom location?
Go To "C:\Program Files (x86)\Common Files\Adobe\Plug-Ins\CS5\File Formats" and look for Camera Raw.8bi file.
If you have that file there, try to download the updated camera raw plugin from the below location.
http://www.adobe.com/support/downloads/thankyou.jsp?ftpID=5371&fileID=5001
In case you ae not able to locate the Camera Raw.8bi file on the above location, then i think you need to re-install PS CS5.
[Moving the discussion to Photoshop General Discussions Forum] -
Help with add file name problem with Photoshop CS4
Frustrating problem: Help with add file name problem with Photoshop CS4. What happens is this. When I am in PS CS4 or CS3 and run the following script it runs fine. When I am in Bridge and go to tools/photoshop/batch and run the same script it runs until it wants interaction with preference.rulerunits. How do I get it to quit doing this so I can run in batch mode? Any help is appreciated. HLower
Script follows:
// this script is another variation of the script addTimeStamp.js that is installed with PS7
//Check if a document is open
if ( documents.length > 0 )
var originalRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.INCHES;
try
var docRef = activeDocument;
// Create a text layer at the front
var myLayerRef = docRef.artLayers.add();
myLayerRef.kind = LayerKind.TEXT;
myLayerRef.name = "Filename";
var myTextRef = myLayerRef.textItem;
//Set your parameters below this line
//If you wish to show the file extension, change the n to y in the line below, if not use n.
var ShowExtension = "n";
// Insert any text to appear before the filename, such as your name and copyright info between the quotes.
//If you do not want extra text, delete between the quotes (but leave the quotes in).
var TextBefore = "Lower© ";
// Insert any text to appear after the filename between the quotes.
//If you do not want extra text, delete between the quotes (but leave the quotes in).
var TextAfter = " ";
// Set font size in Points
myTextRef.size = 10;
//Set font - use GetFontName.jsx to get exact name
myTextRef.font = "Arial";
//Set text colour in RGB values
var newColor = new SolidColor();
newColor.rgb.red = 0;
newColor.rgb.green = 0;
newColor.rgb.blue = 0;
myTextRef.color = newColor;
// Set the position of the text - percentages from left first, then from top.
myTextRef.position = new Array( 10, 99);
// Set the Blend Mode of the Text Layer. The name must be in CAPITALS - ie change NORMAL to DIFFERENCE.
myLayerRef.blendMode = BlendMode.NORMAL;
// select opacity in percentage
myLayerRef.opacity = 100;
// The following code strips the extension and writes tha text layer. fname = file name only
di=(docRef.name).indexOf(".");
fname = (docRef.name).substr(0, di);
//use extension if set
if ( ShowExtension == "y" )
fname = docRef.name
myTextRef.contents = TextBefore + " " + fname + " " + TextAfter;
catch( e )
// An error occurred. Restore ruler units, then propagate the error back
// to the user
preferences.rulerUnits = originalRulerUnits;
throw e;
// Everything went Ok. Restore ruler units
preferences.rulerUnits = originalRulerUnits;
else
alert( "You must have a document open to add the filename!" );you might want to try the scripting forum howard:
http://www.adobeforums.com/webx?13@@.ef7f2cb -
How to use javap with jar files ?
how to use javap with jar files ?
thanksAs long as the jar is on the class path, your gold. So,
javap -classpath myjar.jar mypackage.MyClass
Chuck -
URGENT Help for applet with JAR file in Netscape
I am having Applet with few classes
Html is in /www directory
and all class files are in /www/javaclassfiles
I jared all javaclassfiles with following command
c:\www\javaclassfiles>jar -cvf sample.jar TaxPaymentAppletForm.class *.class
where sample.jar is my jar file and TaxPaymentAppletForm.class is the main applet class file.
THEN I DELETED ALL CLASS FILES & KEPT ONLY SAMPLE.JAR FILE ON SERVER
My html code is like below:
<APPLET CODE="TaxPaymentAppletForm" ARCHIVE="sample.jar" CODEBASE="JavaClassFiles" WIDTH=460 HEIGHT=400></APPLET>
The things are running on IE properly, but not on Netscape. Netscape is giving following error :
java.io.IOException: <null>
at netscape.net.URLConnection.connect(Compiled Code)
at netscape.net.URLConnection.getInputStream(Compiled Code)
* at netscape.applet.AppletClassLoader.grabArchiveFile(Compiled Code)
at netscape.applet.AppletClassLoader.openArchive(Compiled Code)
at netscape.applet.AppletClassLoader.openArchive(Compiled Code)
at netscape.applet.AppletClassLoader.<init>(Compiled Code)
at netscape.applet.AppletClassLoader.getClassLoader(Compiled Code)
at netscape.applet.DerivedAppletFrame$LoadAppletEvent.dispatch(Compiled Code)
at java.awt.EventDispatchThread$EventPump.dispatchEvents(Compiled Code)
at java.awt.EventDispatchThread.run(Compiled Code)
at netscape.applet.DerivedAppletFrame$AppletEventDispatchThread.run(Compiled Code)
# Unable to load archive http://nearbuy_server:90/iras/JavaClassFiles/sample.jar: java.io.IOException: <null>
# Applet exception: class TaxPaymentAppletForm could not be loaded
# Applet exception: class TaxPaymentAppletForm could not be loaded
# Applet exception: class TaxPaymentAppletForm could not be loaded
In netscape also it is sometimes running some times not, without any logical reson.
Any help regarding this is appreciated
manishaFollowing is the more detailed analysis when applet is running and when not
On local server, it is running fine on both IE / Netscape
When I transfered jar file to live server
On IE it is running for the first time and then onwards not running, If I clear the catch then again applet is running.
For second time it is giving following error :
IOException Loading Archive: http://dev1.janusx-collections.com/iras/JavaClassFiles/AppletForm.jar
java.io.IOException: dev1.janusx-collections.com:80//iras/JavaClassFiles/AppletForm.jar
at com/ms/net/wininet/http/HttpInputStream.connect
at com/ms/net/wininet/http/HttpInputStream.<init>
at com/ms/net/wininet/http/HttpURLConnection.createInputStream
at com/ms/net/wininet/WininetURLConnection.getInputStream
at com/ms/vm/loader/JarArchiveSet.loadNextJar
at com/ms/vm/loader/JarArchiveSet.getResourceBits
at com/ms/vm/loader/JarArchiveSet.getClassData
at com/ms/vm/loader/ResourceLoader.getClassData
at com/ms/vm/loader/URLClassLoader.findClass
at com/ms/vm/loader/URLClassLoader.loadClass
at com/ms/vm/loader/URLClassLoader.loadClass
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.run
at java/lang/Thread.run
java.lang.ClassNotFoundException: TaxPaymentAppletForm
at com/ms/vm/loader/URLClassLoader.loadClass
at com/ms/vm/loader/URLClassLoader.loadClass
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.run
at java/lang/Thread.run
ON Netscape it is NOT running at all on from live server and error is as given in above first post.
manisha
Maybe you are looking for
-
Hi there, I purchased a new MacBook Air on Sunday and am using OS X Yosemite 10.10. Unfortunately since then I am having problems with connectivity with certain websites. It is not just a problem with my MacBook Air, because I also have a MacBook an
-
Why does my ipod no longer play all the items in a playlist?
Why does my ipod no longer play all the items in a playlist? I have to go to each item individually to select it as it no longer goes from one item to the next.
-
Director 8 - how do I create a pull down menu
I have only been using Director for a short while and I am trying to figure out how to create an interactive pull down menu. There would be a title (click on title) then a series of Chapters would show up under the title. By clicking on a chapter (or
-
Alternative Reconcialtion account while doig the MIRO
Hi All, One of the cleint required alternative Reconcialtion accoutn while doign the MIRO. Scenario like this there is one Vendor 'A' used supplies Raw material and Serives to company. Business is not intrested to create new vendor. But they needs di
-
RSPO_RID_SPOOLREQ_DISP - Different Formats
Hi , I'm using the function below to look at spools in a program I have written. But, if you have spools of different formats, it does not display all of them just the first one from the Internal table passed in. Id there a way around this using a di