开发者

How to create classes and interfaces in Linux without using an IDE

开发者 https://www.devze.com 2022-12-31 16:19 出处:网络
I am currently writting programs in linux like this: From the command line I do开发者_运维百科 following steps:

I am currently writting programs in linux like this: From the command line I do开发者_运维百科 following steps:

$ touch project.java
$ nano project.java

and I write the code.

I have questions: how can I create new classes, interfaces and so on? Because in IDE like Betbeans I can right click on projects name with and choose "create new class" or "create new interface" and it is created but how do it in Linux if I dont use an IDE?


If you don't use an IDE, you type everything up yourself, with a command line editor - emacs, vi, or nano, like you were using before. (or CAT >> for serious pros).

An Interface looks like this : ( Read Java Sun's tutorial for more about Interfaces! )

interface Bicycle {

       void changeCadence(int newValue);   // wheel revolutions per minute

}

A Class looks like this (Read Java Sun's tutorial for more about Classes!) :

class Bicycle {   
       int cadence = 0;    
       void changeCadence(int newValue) {
            cadence = newValue;
       }
}

Etc, it's all in the documentation. Keep reading Java's handy tutorial and you'll find it all.


The current approach works, if you want to avoid IDEs (except the touch is unnecessary).

Just type the entire source code yourself.

For example to create a class called Foo, use your preferred editor and edit a file Foo.java with the following content:

public class Foo {
}

Save and compile and you're done.

0

精彩评论

暂无评论...
验证码 换一张
取 消