Newbie help with JAR files
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,
Roy
R_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
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.
-
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...
-
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. -
Newbie help with editing files in DW CS3
I am new to using Dreamweaver, and I am having trouble with
trying to edit existing files using DW CS3. When I open an existing
file on my local site, DW converts some of the code using &.
This is a problem because I need to edit the file just as it was
originally written, so I can save it after editing and upload to my
website.
In my Preferences, I have Code Rewriting set to:
-Rewrite Code: Fix invalidly nexted and unclosed tags
[Unchecked]
-Rewrite Code: Rename form items when posting [Checked]
-Rewrite Code: Remove extra closing tags [Unchecked]
-Never rewrite code: In files with extensions .as .asr .asc
.asp .ascx .asmx .aspx .cfc .cfm .cfml .config .cs .ihtml .js .jsp
.php .php3 .vb .xml .xsl .xslt .xul
-Special characters: Encode <, >, &, and " in
attribute values using & [Unchecked]
-URL encoding: Do not encode special characters
-Active Content: Insert using browser-safe scripts [Checked
by default]
-Active Content: Convert tags to scripts on file open
[Unchecked]
Today, I opened a file with an .xml extension, and DW rewrote
the special characters > and '. Since I have in my preferences
to Never rewrite code in .xml, I don't understand why DW is
rewriting the code. Also, in my preferences I have unchecked the
Special Characters, so why is DW still rewriting the code?
Do I have some of the Code Rewriting preferences set wrong?
Is there another place I need to tell DW not to rewrite
existing code?
Thanks for your help!
CyndiIt imported both, but only shows you the raw file. Ever. What you see and what you edit will only be the raw file. The associated JPG file will follow the raw file around if you move it or rename it using Lightroom, but other than that, Lightroom will ignore it. You could safely delete the JPG, and Lightroom wouldn't complain--probably wouldn't even notice.
There's a preference you can set that will cause JPGs to be imported as separate images. Then you'd be able to see both of them and edit them separately. That preference won't take effect on images that are already in the catalogue, but will affect all future imports.
Hal -
Newbie, help with .AVI files!
I am trying to put .AVI files on my imovie hd, but when they eventually load there is nothing there but blackness. I am trying to get these files on imovie hd so that i can make my own dvd. I really dont know what i might need to do. Do I convert the avis to something? If so, what program would be used?
Thanks
NickHi Nicholas,
ffmpeg is a very mighty conversion tool (besides the pro $$$ tools as Compressor), but as you experienced, no that convenient; indeed you hav eto install manually all that libraries, on ffmpegs webiste that is all discrbed in detail.. I can't guide you, I'm using an older version and it was a painstaking process of trial&error... ;-))
BUT...
you haven't told us, what codec is INSIDE the avi... avi is, as .mov, just a media container, containing many flavors of compression codecs, from sorenson, to mp4, from pic to divx....
you haven't told where these avis come from (... or you don't dare to tell us ), but there's a high chance, that it contains just plain mpeg1/2....
in that case, there's some other, much more convenient tool on the market,
have a look here for Streamclip, it accepts .avi containers too....
it's free, for mpeg1 it works "as is"; I would give that a try, before juggling with encoders... ;-)))
you would help us with diagnosis&therapy, when telling us where these avis come from... -
Thank you in advance folks!
I have a Audio TS & Video TS files and I want to bring into iMovie to slice/cut part of the video at the end.
Can I convert Audio/Video TS files to a format I can bring into iMovie to splice the end and send to iDVD.
I want quality to be as good as Audio/Audio TS files.
Again many thanks!!You need to convert the VOB files back to DV which iMovie is designed to handle. For that you need mpegStreamclip:
http://www.apple.com/downloads/macosx/video/mpegstreamclip.html
which is free, but you must also have the Apple mpeg2 plugin :
http://www.apple.com/quicktime/mpeg2/
which is a mere $20.
Another possibility is to use DVDxDV:
http://www.dvdxdv.com/NewFolderLookSite/Products/DVDxDV.overview.htm
which costs $25.
Obviously the foregoing only applies to DVDs you have made yourself, or other home-made DVDs that have been given to you. It will NOT work on copy-protected commercial DVDs, which in any case would be illegal. -
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]
Maybe you are looking for
-
Need help in writin a trigger---Very Urgent
Help me in creating the trigger with below specifications. "We want to reject record deletions where DATE_APPROVED_PROV is not null or NLA_PROV_DONE is not null We want to reject updates where (DATE_APPROVED_PROV is not null or NLA_PROV_DONE is not n
-
SQL query that returns exclusive rows from groups
I'm using modified scott/tiger data for this. I've got two tables DEPT_X DEPTNO DNAME LOC CODE_ID SUB_DEPTNO 10 ACCOUNTING NEW YORK 111 101 10 SALES ATWN 111 102 10 SALES BT
-
How can i find how many smartforms using a particular smart style
hi experts , how can i find how many smartforms using a particular smart style thnks in advance
-
NIST conformance tests using JUnit
I haven't seen anyone from Oracle on the [email protected] mailing list, so I'm posting this here just to let you guys know. I've been working on recasting the NIST DOM test suite for Java to use JUnit and posted an initial release last night. The te
-
Multiple cost of sales account
In OBYC GBB system picks up the COGS account where the entry needs to get posted at the time of GI (MIGO), is there any way to get G/l (COGS) accounts getting posted with ignoring valuation class which gets maintained in material master and by taking