• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

creating a java executable from a package with jar and manifest

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.

I have tried for two hours searching many forums, but could not manage to make my package executable. I have done evrything in notepad, terminal and linux.

My java package path /user/name/documents/mywork/filesystem -> filesystem is the package
in filesystem i got six classes with main class as executefilesystem.java and in /mywork folder i got some textfiles for working in the main class such as read write etc

now how should I run and from which folder?

I tried running from being in filesystem folder by typing in terminal jar cvf filesystem.jar *
it makes filesystem.jar and manifest file which is empty
I added in manifest file
MAIN-CLASS: executefilesystem //->with a newline
and after I failed running the jar as executable modifed the manifest by addind filesystem.executefilesystem AND also filesystem/executefilesystem

Everytme i tried running java jar filesystem.filesystem.jar or java -jar filesystem.jar
giving me either could not load main class OR unable to access jar file filesystem.jar

This is my last [art before I run my simple access control program but I cant seem to make it executable!!!

what am I doing wrong?
 
Bartender
Posts: 15741
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does your manifest file look like, and how do you add it?
 
Mohammad Ashari Rahman
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:What does your manifest file look like, and how do you add it?



Manifest-Version: 1.0
Created-By: 1.8.0_45-b14 (Oracle Corporation)
Main-Class: filesystem.ExecuteFileSystem

----

After the filesystem.ExecuteFileSystem I enter once to give it a newline and save the file
 
Stephan van Hulst
Bartender
Posts: 15741
368
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you save it, but you don't add it to the jar?

It's a good idea to structure your projects. Having a package folder outside of a project folder is generally a bad idea. Lets say your project is called FileSystem. This is how you could structure it:

  • FileSystem/

    • bin/


    • dist/


    • src/
      • filesystem/
        • ExecuteFileSystem.java

      • META-INF/
        • MANIFEST.MF

When you have the command prompt open in the project folder (FileSystem/), you can run the following commands:

The first command will compile your source code in the src/ folder and generate classes in the bin/ folder.
The second command will create a jar file in the dist/ folder and include the manifest file from the src/ folder and the filesystem package from the bin/ folder.
The final command will run the jar file from the dist/ folder.
 
Mohammad Ashari Rahman
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will try this way...thanks:)
 
reply
    Bookmark Topic Watch Topic
  • New Topic