Text-based programs outside of JCreator

V

Vincent Liu

Hello all, I'm in need of a bit of beginners' Java help:

I've made a text-based four-function calculator, and it works fine in
the JCreator general output pane (the place where System.out displays
text and you can enter input).

How do I run the .java file outside of JCreator though? When I try to
open the BasicCalculator.java file with java.exe, nothing happens.

Thanks.
 
M

markspace

How do I run the .java file outside of JCreator though? When I try to
open the BasicCalculator.java file with java.exe, nothing happens.


You don't run the .java file, you run the .class file (or .jar file). A
class file or Jar file should be made by JCreator. If not, take a look
here:

<http://download.oracle.com/javase/tutorial/getStarted/cupojava/win32.html>

(There's one for Linux if you're using that too, look on the side bar on
the left.)
 
V

Vincent Liu

Do you mean .jar file, or did JCreator actually make you a rar file?
Anyway, to make a jar executable, seehttp://www.skylit.com/javamethods/faqs/createjar.html

Thanks!

Oh oops sorry, I meant a .jar file.

I created the BasicCalculator.jar file, but when I double click it,
nothing happens. Also, when I try to execute the .jar file in the
black command window, it sucks the command up and pretends nothing
happened...if I try to execute the class file in the command window,
everything works out fine though (so something is wrong with the way
I'm making my .jar file or something). I opened up the .jar file's
contents and made sure that there was both the BasicCalculator.class
and the META-INF folder, which had MANIFEST.MF, which contains

Manifest-Version: 1.0
Created-By: 1.6.0_22 (Sun Microsystems Inc.)
Main-Class: BasicCalculator

I tried this with another program that I made and replaced the Main-
Class and other parts as necessary to the same avail...And I tried
both the JCreator way and command window way. If you have ideas, I'd
be glad to know. Thanks again!
 
V

Vincent Liu

Apparently I've been using the wrong command to try to run the .jar
file. Now after using the right command, the window says

Failed to load Main-Class manifest attribute from
BasicCalculator.jar
 
V

Vincent Liu

Never mind, finally got it to work.
THANKS SO MUCH FOR YOUR HELP, REALLY APPRECIATED.
 
V

Vincent Liu

Finally got it to work!
THANKS MARKSPACE AND MIKE FOR YOUR HELP, REALLY APPRECIATED.
 
J

Jukka Lahtinen

Vincent Liu said:
Never mind, finally got it to work.

What was the last thing you had done wrong and needed to change before
getting it to work?
(Knowing it may help some other newbie..)
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top