• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java programs in vi editor

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i just wanted to know if there is a different way to type java programs in the vi editor? cause i am getting a lot of errors saying 'illegal character'.
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eh I don't understand your question. There will probably be another way but maybe we can spot the problem if you tell us what you're doing. And just some some code that causes those errors. In conclusion TellTheDetails.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Compilation errors? Vi errors?
 
rameez hussain
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well i typed the following code:

package example.hello;

import java.rmi.Remote;
import java.rmi.RemoteException;

public interface Hello extends Remote {
String sayHello() throws RemoteException;
}

i named it Hello.java and then typed Server.java and Client.java too

The programs worked fine in my laptop but theyre giving me errors now when i tried to run them on another server.

Im getting around 35 errors, all in Hello.java and all of them say "illegal character" with some characters which look like garbage. Im not sure if this is vi errors or compiler erros.

I ran javac -d directory Hello.java Server.java Client.java. that is when i got these errors.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd make sure you're saving the file in a sane encoding first, and that it makes sense on the other system as well.
 
rameez hussain
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i dont understand. could you please be more elaborate? i dont know what you mean by encoding. you see im new to java programming. ive just started.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you seeing a lot of ^M sequences at the end of each line? If so, that means you have the dreaded Windows-line-breaks-on-a-Unix-system problem.

Unix uses \n as line breaks. Windows uses \r\n. Notepad can't handle \n -- it will display it as little blocks. Similarly, VI can't handle \r\n -- it will display the \r as ^M.

You should ensure that dos2unix (and it's brother in arms unix2dos) is installed, then run that before editing. The first will replace all \r\n sequences with \n, the other will do the inverse.
 
rameez hussain
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm. I see. But im using Ubuntu. And there is Linux installed on the other server. Its actually my university server, so i cant really install anything there. Im guessing everything thats needed is already installed. And im pretty sure there are no errors in the java programs im using.
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can download the two EXE files for your Windows box here: http://www.bastet.com/

Then use dos2unix.exe before you send the file(s) to your Unix box.
 
I guess everyone has an angle. Fine, what do you want? Just know that you cannot have this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic