Help with JAR Files
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...
Similar Messages
-
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 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.
-
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 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 -
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. -
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 -
hi, first of all sorry if my post is in wrong forum...but my application is done using swing so i am posting this here....and regarding my question...
I have made an GUI using Java swings and my application is working fine. Now i want to make an executable jar file for my GUI. I have read some tutorilas on making jar files and this is what i have done...
i have created a manifest file called mainClass.txt which has
Main-Class: MainWindow ,where MainWindow is my main class name.
Then i ran the jar utility with this command line:
jar cmf mainClass.txt example.jar *.class
With this line, I told jar to create a JAR file (option c) with modifications to the manifest file (option m) as specified within mainClass.txt, naming the JAR file (option f) as example.jar and including everything that matches the pattern *Class
everything is file till now but my problem is ...I have some library files from JFreechart software included in my GUI to generate barcharts..How can i include these library files in my example.jar file..
Kindly help me
Thanks
byeeI had this problem too. I ran my program out of JCreator and it worked flawlessly. I jarred it up into and Executable Jar and I would get a runtime error explaning I have not included the correct libraries.
What I did was look at the error, for example say it said something like:
org.uhoh.PathSys ClassDefNotFound (or something similar to this)
What I did was extract the library that contained that class file. Then in my project file where I kept my classes I made the folder org, then in org I made uhoh. Inside uhoh I copied over PathSys.class.
I hope I addressed the problem you speak of. I am only a novice but this is how I figured it out. If anyone knows a better way let us know =D
Maybe you are looking for
-
Mac keeps crashing to blank black screen how do I fix?
I am having trouble with my macbook pro. It is 15 in mid 2010 Software Mac OS X Lion 10.7.5 please help this problem keeps interupting at random times. Interval Since Last Panic Report: 94125 sec Panics Since Last Report: 10 Anonymous UU
-
Compressor 2 what works for me
I've had my nightmares with compressor 2 and FCP5 on my Quad G5 and finally found a combo that works . I use compressor only to compress the audio to AC3 format. Using it to compress video results in failure with a Quicktime error of zero. So, I expo
-
Best practice for database migration in 11g
Hello, Database migration is required due to OS change. Here, I have two database instances say A and B in the old server where RDBMS_VERSION is 11.1.0.7.0. They need to be migrated into a new OS where the oracle has been installed with version 11.2
-
I would really appreciate some help with this.
-
My iphone has switched itself off and will not turn on
Help!!!!, My I phone has switched itself off for no apparent reason today and now refuses to switch back on again!, hit has been working fine and is less than a year old.