hai friends my academic project is developing an editor for java. please tell me the code to compile and execute the java programme.
waiting for ur reply please
thanq
jwenting 1,889 duckman Team Colleague
if you are incapable of reading the documentation that comes with the JDK (which will tell you how to compile something) and follow a basic tutorial (linked to from that documentation), what makes you think you can create anything in Java (let alone an IDE, a project usually involving dozens of experienced people and many months or even years of effort)?
I don't in fact think it's an "academic project" at all, sounds more like a homework assignment and you didn't pay attention in class...
suneetha 0 Newbie Poster
hello i have written all the code for creating editor. please see this and i stuck up with compiling and executing the programe
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.undo.*;
import java.awt.event.*;
import java.io.*;
import java.lang.*;
import java.util.regex.*;
public class Editor1 extends JFrame implements ActionListener
{
static String select;
BufferedReader br;
JFileChooser fc;
JMenuBar mb;
JScrollPane js;
JMenu file,edit,search,build,run,help;
JMenuItem nw,open,save,saveAs,print,exit,undo,redo,cut,copy,paste,find,replace,goToLineNumber,compile,javadoc,execute;
JTextArea ta;
Font f;
Container c,c1;
String fname;
public Editor1()
{
select=" ";
br=new BufferedReader(new InputStreamReader(System.in));
fc= new JFileChooser();
//go to content pane
c=getContentPane();
//set BorderLayout to c
c.setLayout(new BorderLayout());
//create textarea
ta=new JTextArea(100,100);
//add ta to c
c.add("West",ta);
// creates a scrollbar
js = new JScrollPane(ta,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
c.add(js);
//ta.addActionListener(this);
//set font
f=new Font("sansserif",Font.PLAIN,17);
ta.setFont(f);
//create the menubar
mb=new JMenuBar();
//add mb to c
c.add("North",mb);
//create file,edit,search,build,run,help menus
file=new JMenu("File");
edit=new JMenu("Edit");
search=new JMenu("Search");
build=new JMenu("Build");
run=new JMenu("Run");
help=new JMenu("Help");
//add menus to mb
mb.add(file);
mb.add(edit);
mb.add(search);
mb.add(build);
mb.add(run);
mb.add(help);
//create menu items
nw=new JMenuItem("New");
open=new JMenuItem("Open");
save=new JMenuItem("Save");
saveAs=new JMenuItem("Save As");
print=new JMenuItem("Print");
exit=new JMenuItem("Exit");
undo=new JMenuItem("Undo");
redo=new JMenuItem("Redo");
cut=new JMenuItem("Cut");
copy=new JMenuItem("Copy");
paste=new JMenuItem("Paste");
find=new JMenuItem("Find");
replace=new JMenuItem("Replace");
goToLineNumber=new JMenuItem("Go to line number");
compile=new JMenuItem("Compile");
javadoc=new JMenuItem("Javadoc");
execute=new JMenuItem("Execute");
//add menuitems to menus
file.add(nw);
file.add(open);
file.add(save);
file.add(saveAs);
file.addSeparator();
file.add(print);
file.add(exit);
edit.add(undo);
edit.add(redo);
edit.addSeparator();
edit.add(cut);
edit.add(copy);
edit.add(paste);
search.add(find);
search.add(replace);
search.add(goToLineNumber);
build.add(compile);
build.add(javadoc);
run.add(execute);
nw.addActionListener(this);
open.addActionListener(this);
save.addActionListener(this);
saveAs.addActionListener(this);
print.addActionListener(this);
exit.addActionListener(this);
undo.addActionListener(this);
redo.addActionListener(this);
cut.addActionListener(this);
copy.addActionListener(this);
paste.addActionListener(this);
find.addActionListener(this);
replace.addActionListener(this);
goToLineNumber.addActionListener(this);
compile.addActionListener(this);
javadoc.addActionListener(this);
execute.addActionListener(this);
//close the frame
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent ae)
{
//to know which item is selected
try
{
if(nw.isArmed())
{
ta.setText(" ");
this.setTitle("SMART JAVA EDITOR-UnTitle.java");
}
//end of new */
if(open.isArmed())
{
int i=fc.showOpenDialog(this);
if(i==JFileChooser.APPROVE_OPTION)
{
fname=fc.getSelectedFile().getName();
FileReader fr=new FileReader(fname);
BufferedReader br1=new BufferedReader(fr,1024);
this.setTitle("SMART JAVA EDITOR-"+fname);
String str;
while(((str=br1.readLine()).length())!=-1)
{
ta.append(str+"\n");
}
br1.close();
}
} //end of open
if(save.isArmed())
{
fname=getTitle();
if(fname.equals("SMART JAVA EDITOR-Untitle.java"))
{
int i=fc.showSaveDialog(this);
if(i==JFileChooser.APPROVE_OPTION)
{
fname=fc.getSelectedFile().getName();
}
}
setTitle("SMART JAVA EDITOR-"+fname);
String str;
FileWriter fw=new FileWriter(fname);
BufferedWriter bw=new BufferedWriter(fw,1024);
str=ta.getText();
for(int j=0;j<str.length();j++)
{
bw.write(str.charAt(j));
}
bw.close();
} //end of save
if(saveAs.isArmed())
{
int i=fc.showSaveDialog(this);
if(i==JFileChooser.APPROVE_OPTION)
{
fname=fc.getSelectedFile().getName();
setTitle("SMART JAVA EDITOR-"+fname);
String str;
FileWriter fw=new FileWriter(fname);
BufferedWriter bw=new BufferedWriter(fw,1024);
str=ta.getText();
for(int j=0;j<str.length();j++)
{
bw.write(str.charAt(j));
}
bw.close();
}
} //end of saveAs
/*if(print.isArmed())
{
} //end of print*/
if(exit.isArmed())
{
System.exit(0);
} //end of exit
/* if(undo.isArmed())
{
// UndoRedoDemo urd=new UndoRedoDemo(this.ta,"undo");
//ta.undo();
}*/
/* if(redo.isArmed())
{
}*/
if(cut.isArmed())
{
select=ta.getSelectedText();
ta.cut();
} //end of cut
if(copy.isArmed())
{
ta.copy();
select=ta.getSelectedText();
} //end of copy
if(paste.isArmed())
{
if(!(select.equals(" ")))
ta.paste();
} //end of paste
if(find.isArmed())
{
FindDemo fd=new FindDemo(this.ta);
} //end of find
if(replace.isArmed())
{
ReplaceDemo rd=new ReplaceDemo(this.ta);
} //end of replace
if(goToLineNumber.isArmed())
{
GoToLineNumberDemo gd= new GoToLineNumberDemo(this.ta);
} //end of goToLineNumber
/* if(compile.isArmed())
{
Class c=Class.forName("sairam");
//String xxx="Editor1";
Boolean b=Compiler.compileClass(c);
System.out.println(b);
}*/ //end of compile
/*if(javadoc.isArmed())
{
} //end of javadoc*/
if(execute.isArmed())
{
Runtime rt=Runtime.getRuntime();
Process prc=rt.exec(Editor1);
InputStreamReader is=new InputStreamReader(prc.getInputStream());
} //end of execute
} //end of try
catch(IOException ie)
{
} //end of catch
catch(CannotUndoException be)
{
}
catch(NullPointerException ne)
{
}
catch(ClassNotFoundException c)
{
System.out.println("class");
}
} //end of paint()
public static void main(String args[])throws IOException
{
//create the frame
Editor1 e=new Editor1();
e.setTitle("SMART JAVA EDITOR-Untitle.java");
e.setSize(800,600);
e.setVisible(true);
}
}
Phaelax 52 Practically a Posting Shark
Use code tags next time, nobody wants to look at unindented code.
Aside from using a few classes that the rest of us don't have and so we can't run it, all I really see so far is you've constucted the GUI.
For compiling and running classes, you'll really need to understand how to do it through the command prompt. Look up the docs on the Process and Runtime classes.
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.