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 guys

does 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.

Similar Messages

  • How to create a .exe file with eclipse 3.1

    Hello every body. I want to know how create a .exe file with eclipse 3.1. A friend tell me it's possible but he forgot how ! So I ask my question ay you, how can I do that? I think it's like in Dev-C++, when he compiling the programme he create
    a .exe file but in eclipse, i don't know how do that. Please help me, I have finish some programs but I don't know how create .exe file for give their at my friend.
    Thank's.
    P.S : I'm a young french so maybe there are some mistake on my post. I hope you understand it.

    There might be a plugin in eclipse to do this, but I don't know what it is.
    The normal way to deploy a program is to create an executable jar file. This will be a .jar not a .exe.
    Or you can try ggogle.
    http://www.google.co.uk/search?q=java+exe

  • Problems creating a Jar-file

    Hello together!
    I have an application working perfectly, but now I want to create a jar-file.
    I created it in eclipse using Export and got the followint error message:
    Failde to load Main-Class manifest attribute from PATH.
    The I changed the manifest.mf and added the following line:
    Main-Class: MyMainClass
    and then I got the following error:
    Invalid or coorupt jarfile.
    If anybody knows what is the problem pls let me know.
    Thanks a lot.

    I am trying to use ant, and I have the built.xml file.
    But when I create the jar file I still have the same problem.
    So my question is how can I make the jar-file inlcuding the ant.
    I mean I did I think the pc created a export.jar, but the same problem.
    Does anybody know how to create a jar file (in eclipse)
    I would really appreciate any kind of help.
    Thanks

  • 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 AM

    Alright, 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

  • Problem building EJB jar file using Eclipse

    Hi,
    Here's my file sturcture.
    ejb\x\y\z\test\
    ejb\x\y\z\test1\
    'ejb' is the root directory.
    The java source files under 'test' have a package name x.y.z.test.
    The java source files under 'test1' have a package name x.y.z.test1.
    I want to build a EJB jar file for 'test' and 'test1' separately. In eclipse when I create an EJB project, I specify the root folder as the source in the java build path settings. So the project explorer in Eclipse shows both the packages since they are under the same root folder. When I try to do 'Export - EJB Jar File', it includes both the 'test' and 'test1' in the .jar. Is there a way to build them separately ?
    Thanks,

    As far as I know, there is no way in Eclipse to specify a package prefix for a source folder. Assuming that you are not using an operating system with support for symbolic links at FS-level, the only way I can think of solving your problem is via linked folders and includes/excludes.
    1. Create two ejb projects in your workspace. Specify locations somewhere independent of where the root of your source tree is located.
    2. Right click on proj1 and select Properties / Java Build Path / Source.
    3. Click Link Source and specify the location to your source root on disk. Click Next.
    4. In the inclusion patterns section, add a pattern that captures classes appropriate for that module. Click Finish.
    5. Delete the original source directory that was created during project creation before leaving Build Path configuration dialog.
    6. Repeat steps 2-5 on the second project, except specify a different inclusion pattern.
    This should produce a project structure that Eclipse will be happy with, but you have to be a little bit careful. Even though you filtered out classes from the view of the java compiler for a particular project, you will still see them listed in the various navigational views (such as Package Explorer or Project Explorer). Don't modify these filtered out files. The project that is supposed to be building them will not react to changes in the other project. You will have to manually refresh (right click on project and select refresh) the other project before the java compiler will see changes.
    Hope this will help you out.
    - Konstantin

  • Problem of packing Jar file in Eclipse

    Hello,
    Thanks for looking my post first :D
    My problem is:
    While I run my program in eclipse, it is fine, but after I pack the whole project to a jar file, the interface is running, but the connection function.
    My program is using my computer to connect a GSM device via bluetooth, the GSM device needs an java API (comm.jar, communication API) with an external driver named *.dll. It means not only the jar file need to be imported to eclipse, but also the *.dll file need to be placed in the java path: Java\jre1.5.0_08\bin\*.dll. And also another file called "javax.comm.properties" needs to be placed in Java\jre1.5.0_08\lib\.
    I think the problem of my jar might be these two files not included in the classpath after exported.
    Does anyone could tell me is there any way to put these two files into the classpath after export? Or what kind of problem am I face actually?
    Thanks very much for help!

    The description is rather confusing.
    What computer exactly are you trying to run this stuff on (it doesn't matter what the software does)?
    A shared library normally msut exist in such a way that the OS can find it and it has to be shared library that is meaningful to the OS (a HP shared library is not going to work on a windows box.)
    There is no such thing as the "java path".
    For windows normally dlls will go in the runtime directory of the application. Windows will find it there. If you want to adjust the path then the path is under control panel -> system.

  • Problem creating an jar file!

    Hello.
    I am trying to create an executable jar file using the following command:
    jar cmf MANIFEST.MF game.jar *.classHowever, I keep receiving the following error:
    java.io.FileNotFoundException: MANIFEST.MF (The system cannot find the file spec
    ified)
            at java.io.FileInputStream.open(Native Method)
            at java.io.FileInputStream.<init>(FileInputStream.java:64)
            at sun.tools.jar.Main.run(Main.java:124)
            at sun.tools.jar.Main.main(Main.java:904)Why am I getting this error and how can I correct this?

    Did you create a file called MANIFEST.MF? Is it in the same directory you are in now?
    And by the way, according to what I see when I run the jar command, you need to specify the jar file first, and then the manifest file:Usage: jar {ctxu}[vfm0Mi] [jar-file] [manifest-file] [-C dir] files ...
    Options:
        -c  create new archive
        -t  list table of contents for archive
        -x  extract named (or all) files from archive
        -u  update existing archive
        -v  generate verbose output on standard output
        -f  specify archive file name
        -m  include manifest information from specified manifest file
        -0  store only; use no ZIP compression
        -M  do not create a manifest file for the entries
        -i  generate index information for the specified jar files
        -C  change to the specified directory and include the following file
    If any file is a directory then it is processed recursively.
    The manifest file name and the archive file name needs to be specified
    in the same order the 'm' and 'f' flags are specified.
    Example 1: to archive two class files into an archive called classes.jar:
           jar cvf classes.jar Foo.class Bar.class
    Example 2: use an existing manifest file 'mymanifest' and archive all the
               files in the foo/ directory into 'classes.jar':
           jar cvfm classes.jar mymanifest -C foo/ .

  • Having problems creating a zip file with Japanese language character names

    I have a bunch of files with names in Japanese characters (also Chinese, Korean, Spanish etc, but this will do for an example). The encoding is Unicode.
    I wish to be able to put them in a zip file, then extract them again using any old zip tool (WinZip,PKZip,7-Zip etc)
    Trouble is, every time I do it, the files inside the zipfile end up with garbage character names. The contents of the files are fine, though.
    I'm aware that there used to be a bug in the java.util.zip.* classes regarding character encodings (http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=5bd4fe01ad8a7b4ec89afef5005da?bug_id=4244499) but as far as I can see it's supposed to have been fixed I have also tried the ZipOutputStream class from apache which allows you to set the encoding manually - no luck there either (just many different varieties of garbage characters)
    Test code below. What am I missing here?
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.FileReader;
    import java.io.IOException;
    public class ZipTest {
    static String uniqueFileName = "&#35199;&#12288;&#32020;.txt";
    public static void main(String[] args) {
    try {
    standardZip();
    apacheZip();
    } catch (IOException fe) {
    System.out.println("problem in file - exception " + fe.getMessage());
    public static void apacheZip() throws IOException {
    String encoding = "";
    File inputFile = new File(uniqueFileName);
    FileReader reader = new FileReader(inputFile);
    encoding = reader.getEncoding();
    System.out.println("Using Apache - Encoding = " + encoding);
    File zipFile = new File("apacheZip.zip");
    org.apache.tools.zip.ZipOutputStream zipOutputStream = new org.apache.tools.zip.ZipOutputStream(
    zipFile);
    zipOutputStream.setEncoding(encoding);
    org.apache.tools.zip.ZipEntry zipEntry = new org.apache.tools.zip.ZipEntry(uniqueFileName);
    zipEntry.setSize(inputFile.length());
    zipEntry.setTime(inputFile.lastModified());
    zipOutputStream.putNextEntry(zipEntry);
    int c = 0;
    while (c >= 0) {
    c = reader.read();
    if (c >= 0) {
    zipOutputStream.write(c);
    zipOutputStream.closeEntry();
    zipOutputStream.finish();
    public static void standardZip() throws IOException {
    String encoding = "";
    File inputFile = new File(uniqueFileName);
    FileReader reader = new FileReader(inputFile);
    encoding = reader.getEncoding();
    System.out.println("Using Java IO - Encoding = " + encoding);
    File zipFile = new File("standardZip.zip");
    FileOutputStream zipOut = new FileOutputStream(zipFile);
    java.util.zip.ZipOutputStream zipOutputStream = new java.util.zip.ZipOutputStream(zipOut);
    java.util.zip.ZipEntry zipEntry = new java.util.zip.ZipEntry(uniqueFileName);
    zipEntry.setSize(inputFile.length());
    zipEntry.setTime(inputFile.lastModified());
    zipOutputStream.putNextEntry(zipEntry);
    int c = 0;
    while (c >= 0) {
    c = reader.read();
    if (c >= 0) {
    zipOutputStream.write(c);
    zipOutputStream.closeEntry();
    zipOutputStream.finish();

    Emma_Baillie wrote:
    I have a bunch of files with names in Japanese characters (also Chinese, Korean, Spanish etc, but this will do for an example). The encoding is Unicode.
    I wish to be able to put them in a zip file, then extract them again using any old zip tool (WinZip,PKZip,7-Zip etc)
    Trouble is, every time I do it, the files inside the zipfile end up with garbage character names. The contents of the files are fine, though.This is becuase zip tool doesn't support unicode for zip entries. For example WinZip prior to 11.2 does not support Unicode characters in filenames. You need to look for the simillar information for other tools. You can find more on tools on their website.

  • 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

  • Problems creating packaged .h files with javah -jni

    I have all of my .java and .class files in package ClassLib.Satrack.
    My directory structure is C:/SatrackIIP/NavComponent/ClassLib/Satrack.
    I compiled all java files by calling javac ClassLib/Satrack/*.java from NavComponent directory. Then still from NavComponent directory, I call javah -jni ClassLib/Satrack/TrajectoryGenerator. However I am getting an error message:
    Error: Class ClassLib/Satrack/TrajectoryGenerator could not be found.
    Why am I getting this error?

    Fixed it. I should be calling javah -jni ClassLib.Satrack.TrajectoryGenerator and not using dashes in between.

  • Creating a JAR file in RAD

    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.

  • Exporting a jar file with its libraries

    Hi there,
    I have problem while exporting jar files with Eclipse.My program uses db2driver libraries and i want to make stay these library files while exporting the main program but there is no choice to make it like that. And when i execute my program jar file it throws a class not found exception for db2drivers ...
    How can i pack the jar files with my program jar?
    Thanks for help.

    Hi Peter,
    I made the changes but still got the problem...
    here is my .classpath file:
    <?xml version="1.0" encoding="UTF-8"?>
    <classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    <classpathentry exported="true" kind="lib" path="db2jcc_license_cu.jar"/>
    <classpathentry exported="true" kind="lib" path="db2jcc.jar"/>
    <classpathentry kind="output" path="bin"/>
    </classpath>
    when i execute my jar file it throws a ClassNotFoundExeption for DB2Drivers which are in db2jcc.jar ...(my startng class is at src package)
    Thanks..

  • 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

  • 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..

  • I Can't Create my jar File

    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 AM

    Adeyi 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.

Maybe you are looking for