aspose file tools*
The moose likes Beginning Java and the fly likes [Mac] Can't run class files through terminal but NetBeans works fine Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "[Mac] Can Watch "[Mac] Can New topic
Author

[Mac] Can't run class files through terminal but NetBeans works fine

Cristian Malmros
Greenhorn

Joined: May 25, 2010
Posts: 2
edit: Solved it myself. When saving files in Coda I should not save it like: test.java but just test. If I add the .java part it messes things up.

I am running Mac OS X Leopard and I'm using Coda to write my Java with. Since Coda doesn't have its own compiler I need to use the Terminal to compile and run my java files.

I wrote a simple thing that had a jframe with a button and a text field where you could input a few characters. The button didn't do anything and it is just very basic. I used the terminal to go to the folder where the file was and I wrote:



It seemed to work fine and I got no errors. When I tried to run it the little app icon in the dock appeared but then it disappeared right after. It just closed itself. I took the same code and put it into NetBeans and compiled and ran it from there and the thing showed up and it worked right away.

I really want to keep using Coda but I don't want to have to move my code into NetBeans all the time to compile and run it. Does anyone have a clue why it crashes/closes itself right away (the jframe never even shows up) when using the Terminal?

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
You are supposed to write the name of the class with the main method, minus extension at the command line.
javac MyClass.java
java MyClass
If you have an application which appears and vanishes, there may be another sort of error. Are you getting a stack trace from an Exception or anything like that? Does the prompt reappear at the terminal window?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [Mac] Can't run class files through terminal but NetBeans works fine