[TxMt] Re: Java Compile and run

David Howden dhowden at gmail.com
Mon Sep 10 01:13:40 UTC 2012


Hi Michael,

>From what I remember, all entities in Java are "private" by default.
In the case of classes, this means that you can only access (or "see")
it from code within the package it is contained in.  By running the
helloworld.class file, it will try to call the "main" method on a
class called "helloworld". If the class "helloworld" is not declared
public, it won't be able to see it (hence the "NoClassFoundException"
you were getting).

Cheers,

David.

On 10 September 2012 10:57, Michael Sheaver <msheaver at earthlink.net> wrote:
> Date: Mon, 10 Sep 2012 07:08:15 +1000
> From: David Howden <dhowden at gmail.com>
> To: TextMate users <textmate at lists.macromates.com>
> Subject: [TxMt] Re: Java Compile and run
> Message-ID:
> <CAP2kWKHah0sAKbNzh9GFwb6q-YfzJ=dqrSUDHgxrLoe9rvjqvg at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
>
> Right, so I've had a little play with this.
>
> 1. Create a file called helloworld.java and save it on your desktop.
> 2. Put this in it:
> public class helloworld {
>    public static void main(String[] args) {
>        System.out.println("Hello World!");
>    }
> }
> 3. Save again!
> 4. Cmd+R
>
> This runs perfectly for me in TM2 using the default Java bundle.  Try
> it on your version (checking and double checking the filename and the
> class name match exactly).
>
> Cheers,
>
> David
>
>
> Hey David,
>
> I am pleasantly surprised, but your suggestion was what I needed!
> Apparently, the code I had used (below) didn't have the class defined as
> public. I don't understand why that would make a difference, but hey, it
> works, and that's what really matters.
>
> Many thanks!
> Michael
>
> class HelloWorldApp {
>     public static void main(String[] args) {
>         System.out.println("Hello World!"); //Display the string.
>     }
> }
>
>
>
>
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate


More information about the textmate mailing list