• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

 
Marshal
Posts: 76860
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Police line, do not cross. Well, this tiny ad can go through:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic