This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Unable to run a java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Unable to run a java program" Watch "Unable to run a java program" New topic
Author

Unable to run a java program

Ilakya Mukunth
Ranch Hand

Joined: Mar 13, 2012
Posts: 57
I am a beginner in java. I ma trying to compile the Helloworld in Mac OS X 10.6.8 in terminal. I saved the program under user directory. In terminal, I try to run the program from the same path.(Please refer the screen shot below). Applications->Utilities->JAVA preferences shows 64 bit in the first line.
Please help me. I just started my first lesson in java and its a work stopper.

Here is my program

public class One
{
public static void main(String[] a)
{
System.out.println("Hello World");
}
}

This is the output from Terminal

Last login: Tue Mar 13 22:17:49 on ttys000
popo:~ popo$ ls
Desktop Movies Public
Documents Music Send Registration
Downloads One.java Sites
Library Pictures programs
popo:~ popo$ javac One.java
One.java:1: class, interface, or enum expected
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
^
One.java:1: illegal character: \92
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
^
One.java:1: illegal character: \92
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
^
One.java:1: illegal character: \92
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
^
One.java:1: illegal character: \92
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
^
One.java:1: illegal character: \92
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
^
One.java:2: illegal character: \92
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
^
One.java:2: illegal character: \92
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
^
One.java:2: illegal character: \92
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
^
One.java:2: illegal character: \92
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
^
One.java:2: class, interface, or enum expected
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
^
One.java:3: illegal character: \92
{\colortbl;\red255\green255\blue255;}
^
One.java:3: illegal character: \92
{\colortbl;\red255\green255\blue255;}
^
One.java:3: illegal character: \92
{\colortbl;\red255\green255\blue255;}
^
One.java:3: illegal character: \92
{\colortbl;\red255\green255\blue255;}
^
One.java:3: class, interface, or enum expected
{\colortbl;\red255\green255\blue255;}
^
One.java:4: illegal character: \92
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
^
One.java:4: illegal character: \92
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
^
One.java:4: illegal character: \92
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
^
One.java:4: illegal character: \92
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
^
One.java:4: illegal character: \92
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
^
One.java:5: illegal character: \92
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
^
One.java:5: illegal character: \92
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
^
One.java:5: illegal character: \92
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
^
One.java:5: illegal character: \92
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
^
One.java:5: illegal character: \92
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
^
One.java:5: illegal character: \92
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
^
One.java:5: illegal character: \92
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
^
One.java:5: illegal character: \92
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
^
One.java:5: illegal character: \92
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
^
One.java:5: illegal character: \92
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
^
One.java:5: illegal character: \92
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
^
One.java:5: illegal character: \92
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
^
One.java:5: illegal character: \92
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
^
One.java:5: illegal character: \92
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
^
One.java:5: illegal character: \92
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
^
One.java:5: illegal character: \92
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
^
One.java:7: illegal character: \92
\f0\fs24 \cf0 public class One\
^
One.java:7: illegal character: \92
\f0\fs24 \cf0 public class One\
^
One.java:7: illegal character: \92
\f0\fs24 \cf0 public class One\
^
One.java:7: illegal character: \92
\f0\fs24 \cf0 public class One\
^
One.java:8: illegal character: \92
\{\
^
One.java:8: illegal character: \92
\{\
^
One.java:8: ';' expected
\{\
^
One.java:9: illegal character: \92
public static void main(String[] a)\
^
One.java:10: illegal character: \92
\{\
^
One.java:10: illegal character: \92
\{\
^
One.java:11: illegal character: \92
System.out.println("Hello World");\
^
One.java:12: illegal character: \92
\}\
^
One.java:12: ';' expected
\}\
^
One.java:12: illegal character: \92
\}\
^
One.java:13: illegal character: \92
\}}
^
52 errors

Koen Aerts
Ranch Hand

Joined: Feb 07, 2012
Posts: 344

Those look like RTF tags in there... so in other words One.java is not saved as a plain text file. Use a text editor not a document editor.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37907
    
  22
Welcome to the Ranch

Agree about text editors. You should also look at our FAQ.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to run a java program
 
Similar Threads
Please Help! Having problems with class program
Where do the CLDC class files need to be placed?
Error problems
Replace unuseless characters in a String
how to insert data into existing file