LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-22-2004, 01:28 AM   #1
vdogvictor
Member
 
Registered: Feb 2004
Distribution: Arch
Posts: 498

Rep: Reputation: 31
Want to use Emacs for java but have a few questions


Ok. I want to do java programming in linux. I was using DOS (well win98 with "bootgui=0" in my system.ini file I believe") and I used edit....so emacs should be a big jump. Well I know emacs can become this great java buddy thing of mine, but how easy is it going to be to make it this? I want java indenting and syntax coloring. Is this default in most distros (plan to use slackware 9.1 or gentoo 1.4 stage 3) or must I do something???

Okay now to the more important part of the post! I understand u can use a JDE w/ emacs, but it still requires a SDK??? I don't really understand this part. does it just run javac and such for you??? The reason I want to use Emacs so bad is because it is so much smaller than suns SDK...is there a smaller java compiler (I noticed gcc-java is in slack...but I don't know what that really means or how to use it) I don't need most of the stuff in the SDK...all I need are the commands java and javac. And I also need the standard import classes. Why would emacs have a JDE if u still have to use the SDK to run it? and how exactly is it integrated w/ emacs???
 
Old 06-22-2004, 02:18 AM   #2
nimra
LQ Newbie
 
Registered: May 2004
Posts: 28

Rep: Reputation: 15
syntax highlighting for the most common languages are standart (also for java). Just create a file with termination .java and start it with emacs. If now syntaxhighlighting is done, you must select it manually. (You can also turn syntax highlighting on by default, just add the comand in the .emacs file).
In any case, you need at least the javac and the java programs. Emacs is the text editor to write to code, with javac you compile your code and create a bytecode which can be executed by the java comand...
Changing to an other IDE SDK is a question of taste....
 
Old 06-22-2004, 12:31 PM   #3
vdogvictor
Member
 
Registered: Feb 2004
Distribution: Arch
Posts: 498

Original Poster
Rep: Reputation: 31
What other compilers for java are there? would the gcc-java be fine? I want the smallest one around that is still standard though.

edit: Do they all use the same commands like java and javac. And how can I compile from within Emacs?

Last edited by vdogvictor; 06-22-2004 at 12:32 PM.
 
Old 06-22-2004, 02:27 PM   #4
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Quote:
Originally posted by vdogvictor
edit: And how can I compile from within Emacs?
Within emacs:

frist off, if you open your file, at the bottom of the window (in the black line) it looks like this:

edit_status\write_status FileName (mode)--line_number--cursor_location%

if the mode is not java, you can change it by using the command:

M-x java-mode

if the syntax is not highlighted, you can turn it on with:

M-x global-font-lock-mode

to compile within emacs, the easiest way is to open a shell within emacs:

M-x shell

... and then just type your compile string at the command line. Personally, I prefer to use alt-tab to switch between windows and just go back and forth between a shell and the emacs window.

to switch between your .java file buffer and the shell buffer:

M-x b (then optionally type the name of the buffer if it is not shown as the default)

To open files in emacs:

C-x f

To save:

C-x C-s

To save as:

C-x C-w

In all the above examples, 'M' means "meta key" which is usuually the "alt" key and/or the "esc" key. 'C' means the control key. a '-' means both at the same time. So, to save, you would hit cntl and x followed by cntl and s. To open, you'd hit cntl and x followed by f (by itself).

Emacs also supports auto completeion, so if you type M-x ja<tab> it will show you all of the possible options. This goes the same for file names, but you'll need two tabs to get the list.

YOu can also show two buffers at one time with:

M-x 2

and switch in between the two open buffers with

M-x o (or just use the mouse)

That should be enough to get you started.

edit: oh, you'll probably also want to know:

C-k "kills" a line of text from the cursor to the newline

C-w cuts the current region to the kill ring

C-y "yanks" the text back from the kill ring - kinda like paste from a C-k or C-w

regions are stared with C-<space> and then go to the cursor location...

So say I want to take "bar" out of this line:

foo bar gah

I would put my cursor at the beginning of "bar", then C-<space> to start a region, then C-<right arraow> to the end of "bar", then C-w to cut out "bar"

Then I move the cursor somewhere else & do a C-y to paste "bar" at the new cursor location.

.... oh yeah... and.. if you're going to move code between Linux & windows, the tabs are often different, so set a region to your entire file (from start to end) and use:

M-x untabify

to change all the tabs to spaces - then your projects will look the same regardless of the viewing editor's tab stops.

Last edited by BrianK; 06-22-2004 at 02:40 PM.
 
Old 06-22-2004, 06:13 PM   #5
vdogvictor
Member
 
Registered: Feb 2004
Distribution: Arch
Posts: 498

Original Poster
Rep: Reputation: 31
Thanks a lot for all the commands. that should help quite a bit.
 
Old 06-26-2004, 12:02 AM   #6
vdogvictor
Member
 
Registered: Feb 2004
Distribution: Arch
Posts: 498

Original Poster
Rep: Reputation: 31
is this nifty stuff only w/ the xemacs, or does it work with terminal emacs?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Emacs Questions gugamare Linux - Software 1 12-20-2004 08:34 AM
Emacs and Java AaronUFC Linux - Newbie 2 02-14-2004 06:52 PM
EMACS and JAVA AaronUFC Linux - Newbie 2 01-10-2004 10:16 AM
Java:emacs,Sdk,jde naima Programming 7 06-02-2002 03:52 AM
forte/emacs for java questions keirobyn Programming 5 02-05-2002 12:04 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration