Welcome to Dream.In.Code
Become a Java Expert!

Join 149,478 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,686 people online right now. Registration is fast and FREE... Join Now!




illegal start of expession

 
Reply to this topicStart new topic

illegal start of expession, public static void

zemapel
25 Apr, 2007 - 03:21 AM
Post #1

New D.I.C Head
*

Joined: 25 Apr, 2007
Posts: 2


My Contributions
hi all , i'am new in java and i have this problem. my prgramm is

import java.io.*;
import javax.comm.*;

public class Sarla1 {
CommPortIdentifier portId = null;
SerialPort asyncPort = null;
OutputStream op = null;
InputStream ip = null;
public void connect() {
try {
portId = CommPortIdentifier.getPortIdentifier("COM3");
} catch (Exception x) {
System.out.println(x);
}
try {
asyncPort = (SerialPort) portId.open("vLab serial port", 4000);
} catch (Exception x) {
System.out.println(x);
}
try {
asyncPort.setSerialPortParams(57600, SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (Exception x) {
System.out.println(x);
}
try {
asyncPort.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN & SerialPort.
FLOWCONTROL_RTSCTS_OUT);
} catch (Exception x) {
System.out.println(x);
}
try {
op = asyncPort.getOutputStream();
} catch (Exception x) {}
try {
ip = asyncPort.getInputStream();
} catch (Exception x) {}
String code = "E2231\r";
String message = "atdt2310994186\r";
try {
op.write( message.getBytes());
} catch (Exception x) {}
String rxMessage="";
for (;;) {
try {
if (ip.available()>0) {
int k=ip.read();
System.out.print((char)k);
rxMessage = rxMessage+(char)k; if (rxMessage.indexOf("CONNECT")>0) break;
}
} catch (Exception x) {}
}

try {
for (int k=0; k<30; k++) {
String code = "E3701\r";
op.write(code.getBytes());
}
} catch (Exception x) {}

rxMessage="";
for (;;) {
try {
if (ip.available()>0) {
int k=ip.read();
}
} catch (Exception x) {}
System.out.print((char)k);
rxMessage = rxMessage+(char)k; if (rxMessage.indexOf("STOP")>0) break;
}
public static void main(String arg[]) {
Sarla1 ss = new Sarla1();
ss.connect();
}
}

the error message is public static void main(string arg []) in the fifth row from the bottom, and i can not figure it out. thanks!!!
User is offlineProfile CardPM
+Quote Post

rex-mundi
RE: Illegal Start Of Expession
25 Apr, 2007 - 03:59 AM
Post #2

New D.I.C Head
*

Joined: 13 Apr, 2007
Posts: 24


My Contributions
QUOTE

CODE

    public static void main(String arg[]) {
       Sarla1 ss = new Sarla1();
       ss.connect();
   }


the error message is public static void main(string arg []) in the fifth row from the bottom, and i can not figure it out. thanks!!!



I think that you will find that you need the code to be the following:

CODE

public static void main (String [] args)
{
    {...}
}


Hope that it helped.
User is offlineProfile CardPM
+Quote Post

zemapel
RE: Illegal Start Of Expession
25 Apr, 2007 - 10:06 AM
Post #3

New D.I.C Head
*

Joined: 25 Apr, 2007
Posts: 2


My Contributions
QUOTE(rex-mundi @ 25 Apr, 2007 - 04:59 AM) *

QUOTE

CODE

    public static void main(String arg[]) {
       Sarla1 ss = new Sarla1();
       ss.connect();
   }


the error message is public static void main(string arg []) in the fifth row from the bottom, and i can not figure it out. thanks!!!



I think that you will find that you need the code to be the following:

CODE

public static void main (String [] args)
{
    {...}
}


Hope that it helped.


thanks for your time , i try that but no results. i stil have the same error. some other idea?

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 03:28PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month