• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The stupidest question

 
Michael Huber
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I want to make a program that I have independant of java. I am using j2sdk1.4.1_01 and I found out that jar files are the best for this. So in my Command Prompt I type the following:

jar cf Hello.java

it gives me a menu but not the jar file. Anyone could give this idiot a step by step guide to creating a jar file and how to view it??? PLEASE

yes I am dumb, I read the tutorial at http://java.sun.com/docs/books/tutorial/jar/basics/index.html
but I still don't get it

thanks, any help is much appreciated.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a stupid question. If you haven't used UNIX "tar", the jar command's syntax is vaguely confusing. Your command line is simply missing the name you want the jar file to have:

jar cf myjar.jar Hello.java

Of course, you typically don't want to put .java files into a jar, but .class files.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to create an executable JAR, one that could be run on a properly configured system by simply double-clicking, you might like to follow the instructions in the "Creating an Executable JAR File" thread.
 
Michael Huber
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read the instructions for creating a JAR but when I open the zip file (I use WinRAR) and double click on Hello.class (I did a quick Hello world for just to test it out) I get a file that opens and its basically all my code in funny lettering.

I did everything like the post said, I just substituted all the Foo.class with Hello.class

I even added a carriage return on the
Main-Class: Hello

thanks for all your help!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic