Newbie with NetBeans and .JAR files...

L

Leonard Slatkin

I'm taking my first Java course, and we're using the NetBeans IDE.

I'm trying to use .JAR files:

For example, I have a package (all in a folder with the same name) that
compiles and executes fine. I make a JAR out of it using NetBeans, and
mount TestJar.jar with File> Mount Filesystem> Archive files.
The package seems to mount just fine: I can open the source files I
included (they are read-only), and all the .class files are there, but
when I try to execute the main class

FireSupport/MyMainClass.java [0:0] No file named
FireSupport/MyMainClass.java exists on disk in TestJar.jar.
Therefore it may not be compiled with an external compiler.
You may need to check it out from version control or save some changes
to it.
Errors compiling MyMainClass.

What am I doing wrong?

Thanks for any help!



This is how I make the JAR file:
File> New > JAR Archives > JAR Recipe and:
enter TestJar as the name,
select All Files in the Recipe Filter,
and ADD the folder that contains all my files in the package
I click "Generate" on the JAR Manifest page, add the line:
Main-Class: MyMainClassName
and click Finish.

Then, I right-click on the new TestJar file in the Explorer
[Filesystems], and choose Compile.

A file called TestJar.jar is created, and if I unzip it, everything
looks okay inside.
 
A

Andrew Thompson

Leonard Slatkin said:
I'm taking my first Java course, and we're using the NetBeans IDE.

Your instructor is an idiot if they specified you
use NetBeans to learn Java - use the command line.
I'm trying to use .JAR files:

I do not have the time to figure out why a newbie
making jar's using an advanced IDE does not work.

(Though, wild guess, it might be a missing manifest file)

If you dump the IDE and check out the sun tutorials,
you are probably going to get much more help here..

HTH
 
S

Sudsy

Andrew said:
Your instructor is an idiot if they specified you
use NetBeans to learn Java - use the command line.


Geez, Andrew! Cut the kid some slack!
I've been playing around with Eclipse for the last few days and it
does some things quite well. It's still fragile so you have to make
regular backups of your workspaces and it can be obstructive when
writing code "heads-down" but it does have its place.
I find that it works best for me when I write the code using vi,
import into a project and then use the "Organize imports" function
and the XDoclet processing to generate all the extra files (home
and remote interfaces, deployment descriptors, etc.). Boilerplate
the XDoclet and packaging XML files and you can actually save some
time.
YMMV
 
L

Leonard Slatkin

Andrew said:
Your instructor is an idiot if they specified you
use NetBeans to learn Java - use the command line.


I do not have the time to figure out why a newbie
making jar's using an advanced IDE does not work.

(Though, wild guess, it might be a missing manifest file)

If you dump the IDE and check out the sun tutorials,
you are probably going to get much more help here..

HTH

--
Andrew Thompson
http://www.AThompson.info/
http://www.PhySci.org/
http://www.1point1C.org/

Wow, that was very helpful, thank you! Hope it was worth your valuable
time.
 
A

Andrew Thompson

Sudsy said:
Geez, Andrew! Cut the kid some slack!

It is not 'the kid' with whom I have a problem,
it is the instructor who does not start his/her
students developing 'hello world' apps for
the command line.
I've been playing around with Eclipse for the last few days and it
does some things quite well.

I use Eclipse also, it is great.
I also use Textpad for simple bits of
java code and JSP's.

But I feel all 'newbies' should start with non GUI
apps on the command line, that way, they have a good
chance of figuring the problems thrown up by
the more advanced IDE's themselves.
..It's still fragile so you have to make
regular backups of your workspaces

Not the sort of thing a 'newb' should
have to worry about, eh Sudsy?
and it can be obstructive when
writing code "heads-down"

Which is exactly what a 'newb' needs.
but it does have its place.

Yes, coders who are past the 'newb' stage.

[ I see your point, but in this context I disagree. ]

YMAV (Y M Apparently V) ;-)
 
S

Sudsy

Andrew said:
It is not 'the kid' with whom I have a problem,
it is the instructor who does not start his/her
students developing 'hello world' apps for
the command line.

On that point I heartily agree! Starting out at the command line
with the javadocs in a browser window is definitely the best way
to learn Java.
But then we might just be swimming against the current. ;-)
 
A

Andrew Thompson

Sudsy said:
Andrew Thompson wrote: .....

On that point I heartily agree! Starting out at the command line
with the javadocs in a browser window is definitely the best way
to learn Java.
But then we might just be swimming against the current. ;-)

Only dead fish swim with the current. :)
 
S

Sudsy

Leonard Slatkin wrote:
Wow, that was very helpful, thank you! Hope it was worth your valuable
time.

I think part of the problem is that you haven't defined your
situation very well. You mention a "main class" when most of
us are used to a static class method named main. But then you
can have a main method in each and every one of your classes
(and many of us program that way in order to perform convenient
unit testing).
So perhaps your query would be more appropriate in a forum or
newsgroup dedicated to netbeans? Either that or you might
detail the steps you take to run your "main class" and let the
netbeans afficionados take a stab at it.
Don't shoot the messenger!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top