• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to run a java program

 
Ilakya Mukunth
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 344
Java Linux Oracle
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49364
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Agree about text editors. You should also look at our FAQ.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic