MyJCreator - Program for java compilation and run, version 1 built 10

2 views
Skip to first unread message

Justin

unread,
Aug 13, 2006, 3:39:30 PM8/13/06
to open_p...@googlegroups.com
Basic documentation

This is the documentation for the project My Java Creator , a free  IDE for java compilation and running.The whole software is written in Java and comes under GPL v2. Source code is open as well as free.
Note: You are free to modify to modify the source , provided the modified code also remains open.

version : 1 , built 10
Core developers :  Justin and Nandu
Date     :14 - Aug, 2006


The program basically is  text editor with capabilities for compiling and running a java program. The code is typed in the text area and can be saved. Previously saved files can also  be opened, and compiled or run.

=========================================================

Future requirements
___________________


Primary objectives
--------------------------

  •   Name of the file must appear as the title of the frame
  •   Right click facilty for copy and paste
  •   Mnemonics for all functions
  •   Close faciltiy in File menu




Secondary objectives
------------------------------
  •  Automatic color change for keywords.
  •  Full fledged help facility
  •  Drag and drop facility.
  •  Direct link to JDK documentation.


Demo objectives
----------------------------
  •  Changing skin of the software
  •  Automatic indenting
  •  Status bar.
  •  Tab facility
  •   Autocomplete for commonly used functions
save2.gif
compile.png
MyJCreatorTest.java
new2.jpg
open2.jpg
run.png

nandu

unread,
Aug 13, 2006, 3:55:20 PM8/13/06
to Open Projects For All
Dear justin

Your initiative to approach Google Project is welcomed and
inspiring.All the very best and i extend my sincere support.

Nandu

Justin wrote:
> _*Basic documentation*_


>
> This is the documentation for the project My Java Creator , a free IDE for java compilation and running.The whole software is written in Java and comes under GPL v2. Source code is open as well as free.
> Note: You are free to modify to modify the source , provided the modified code also remains open.
>
> version : 1 , built 10
> Core developers : Justin and Nandu
> Date :14 - Aug, 2006
>
>
> The program basically is text editor with capabilities for compiling and running a java program. The code is typed in the text area and can be saved. Previously saved files can also be opened, and compiled or run.
>
> =========================================================
>
> Future requirements
> ___________________
>
>
> Primary objectives
> --------------------------
>
>

> * Name of the file must appear as the title of the frame
> * Right click facilty for copy and paste
> * Mnemonics for all functions
> * Close faciltiy in File menu
>
>
>
> Secondary objectives
> ------------------------------
>
> * Automatic color change for keywords.
> * Full fledged help facility
> * Drag and drop facility.
> * Direct link to JDK documentation.
>
> Demo objectives
> ----------------------------
>
> * Changing skin of the software
> * Automatic indenting
> * Status bar.
> * Tab facility
> * Autocomplete for commonly used functions --------------070907080803030406010805 Content-Type: image/gif Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="save2.gif" X-Google-AttachSize: 1083
>
> //future enhancements : use of textpane
>
> import javax.swing.*;
> import java.awt.event.*;
> import java.awt.*;
> import java.io.*;
>
> class MyJCreator extends JFrame
> {
>
> Process p =null; // used for executing javac
>
> JMenuBar topBar ;
> JMenu menuFile , menuEdit , menuHelp ;
> JMenuItem itmNew , itmOpen , itmSave , itmClose , itmCopy , itmCut ,
> itmPaste , itmAbout ;
> JTextArea tAreaEditor ;
> JFileChooser myFileChooser , mySaveFile ;
> Container c ;
> String nameOfTheFile ,runPathforJava;
>
>
> String OpenOrSaveFilePath;
>
> //buttons for toolbar
> JButton buttonNew, buttonOpen, buttonSave, buttonCompile , buttonRun ;
> //icons for toolbar
> Icon newIcon, saveIcon, openIcon , compileIcon, runIcon;
>
> MyJCreator ()
> {
> super("My JCreator ");
> c = getContentPane();
> c.setLayout(new BorderLayout());
>
> //adding the text editor
>
> tAreaEditor = new JTextArea (20,40);
> tAreaEditor .setLineWrap(true) ;
>
>
>
> //creates the new file chooser
> myFileChooser = new JFileChooser();
> mySaveFile = new JFileChooser();
>
> topBar = new JMenuBar ();
>
> // adding contents for the menu --> file
>
> menuFile = new JMenu ("File");
>
> itmNew = new JMenuItem ("New");
> itmOpen = new JMenuItem ("Open");
> itmSave = new JMenuItem ("Save");
> itmClose = new JMenuItem ("Close");
>
> menuFile .add(itmNew );
> menuFile .add(itmOpen );
> menuFile .add( itmSave );
> menuFile .add(itmClose );
>
> topBar .add(menuFile );
> //*********************************************
>
> // adding contents for the menu --> Edit
>
> menuEdit = new JMenu ("Edit");
> itmCut = new JMenuItem ("Cut");
> itmCopy = new JMenuItem ("Copy");
> itmPaste = new JMenuItem ("Paste");
>
> menuEdit .add(itmCut );
> menuEdit .add(itmCopy );
> menuEdit .add(itmPaste );
>
> topBar .add(menuEdit );
>
> //*********************************************
>
> menuHelp = new JMenu ("Help");
> itmAbout = new JMenuItem ("About");
>
> menuHelp .add(itmAbout );
> topBar .add(menuHelp );
>
> //*********************************************
>
> //ADDING ACTION LISTENERS FOR THE MENU
> //--------------------------------------------------------------------
> MyMenuListener mm1 =new MyMenuListener ();
>
> itmNew .addActionListener(mm1);
> itmSave .addActionListener(mm1);
>
> itmOpen .addActionListener(mm1);
>
> // edit listeners
>
> itmCut.addActionListener(mm1);
> itmPaste.addActionListener(mm1);
> itmCopy.addActionListener(mm1);
>
> // Help listeners
>
> itmAbout.addActionListener(mm1);
>
>
>
>
> setJMenuBar(topBar);
>
> //___________________________________________________
> //ADDING THE TOOLBAR AND ITS BUTTONS
>
>
> JToolBar togglePanel = new JToolBar();
>
> //creating icon buttons for new, open and save
>
> //creating icons for the buttons
>
> newIcon = new ImageIcon("new2.jpg");
> openIcon = new ImageIcon("open2.jpg");
> saveIcon = new ImageIcon("save2.gif");
>
> compileIcon = new ImageIcon("compile.png");
> runIcon = new ImageIcon("run.png");
>
>
> buttonNew = new JButton(newIcon);
> buttonNew.setToolTipText("Create a new file");
>
> buttonOpen = new JButton();
> buttonOpen.setToolTipText("Open another file");
> buttonOpen.setIcon(openIcon);
>
> buttonSave = new JButton(saveIcon);
> buttonSave.setToolTipText("Save the source code");
>
> //creating the button for compilation and running
> buttonCompile = new JButton(compileIcon);
> buttonCompile.setToolTipText("Compile the source code");
>
> buttonRun = new JButton(runIcon);
> buttonRun.setToolTipText("Run the compiled code");
>
>
> //also add the button for compilation and running
> togglePanel .add(buttonNew );
> togglePanel .add(buttonOpen );
> togglePanel .add(buttonSave );
>
> //for dimension constructor first is width
> togglePanel .addSeparator(new Dimension(40,10));
>
> togglePanel .add(buttonCompile);
> togglePanel .add(buttonRun );
>
> c.add(togglePanel ,BorderLayout.NORTH);
> //_________________________________________________
>
> //ADDING ACTION LISTENERS FOR THE 2 BUTTONS
> //--------------------------------------------------------------------
>
> MyButtonListener butLisn =new MyButtonListener ();
>
>
> /*we use the menu listner object mm1 here, because that class contains
> *actions for new , save, and open , GOt it ?*/
>
> buttonNew .addActionListener(mm1 );
> buttonOpen .addActionListener(mm1 );
> buttonSave .addActionListener(mm1 );
>
> buttonCompile .addActionListener(butLisn );
> buttonRun .addActionListener(butLisn );
>
> JScrollPane myScrollPane = new JScrollPane(tAreaEditor );
>
> c.add( myScrollPane);
>
> }
>
> //LISTENERS FOR COMPILATION AND RUNNING
>
> private class MyButtonListener implements ActionListener
> {
> public void actionPerformed(ActionEvent e)
> {
>
> if(e.getSource() == buttonCompile )
> {
> Process pCompile = null;
> Runtime rCompile = Runtime.getRuntime();
> Runtime rt = Runtime.getRuntime();
> //r.traceInstructions(true);
> try
> {
>
> Process proc = rt.exec("javac "+OpenOrSaveFilePath);
> InputStream stderr = proc.getErrorStream();
> InputStreamReader isr = new InputStreamReader(stderr);
> BufferedReader br = new BufferedReader(isr);
> String line = null;
> String fullList = "";
>
> while ( (line = br.readLine()) != null)
> fullList = fullList + line+"\n";
>
> int exitVal = proc.waitFor();
> System.out.println("Process exitValue: " + exitVal);
>
> if( fullList != null)
> JOptionPane.showMessageDialog(null, fullList, "Compile errors",JOptionPane.ERROR_MESSAGE ) ;
>
> System.out.println(fullList);
>
> //pCompile = rCompile.exec("javac "+OpenOrSaveFilePath );
>
> }
>
> catch(Exception ex)
> {
> }
>
> }//end of if condition
>
> if(e.getSource() == buttonRun )
> {
> Process pRun = null;
> Runtime rRun = Runtime.getRuntime();
> try
> {
> System.out.println("trying to run the program");
>
>
> //OpenOrSaveFilePath contains the word ".java" --> so
> //we have to remove that and it is stored in runPath
> String runName = nameOfTheFile.substring(0,nameOfTheFile.length() - 5);
>
> System.out.println(runName);
> pRun = rRun .exec("java -classpath "+ runPathforJava +" "+runName );
> }
> catch(Exception ex)
> {
> }
> }//end of if condition
>
> } //end of actionPerformed
> } // end of inner class
>
> //******************************************************************************
> //******************************************************************************
>
> private class MyMenuListener implements ActionListener
> {
> public void actionPerformed(ActionEvent e)
> {
>
> if( e.getSource() == itmNew || e.getSource() == buttonNew )
> tAreaEditor.setText("");
>
>
>
>
> if( e.getSource() == itmOpen || e.getSource() == buttonOpen )
> {
>
> FileInputStream readFile;
> int returnval = mySaveFile .showOpenDialog(c) ;
> File f =mySaveFile .getSelectedFile() ;
>
>
>
> String openFilePath = f.getPath() ;
> OpenOrSaveFilePath = openFilePath;
> nameOfTheFile = f.getName();
> runPathforJava = f.getParent() ;
>
> System.out.println("The path of the file is: "+ runPathforJava );
>
>
>
> try
> {
> readFile = new FileInputStream( openFilePath );
> byte data[] = new byte[readFile.available()];
>
>
> readFile.read(data);
> String byteText = new String(data);
> tAreaEditor .setText(byteText);
>
>
> }
>
> catch(Exception excp)
> {
> System.out.println("get the hell out of here");
> }
>
>
>
>
> }
>
>
> if( e.getSource() == itmSave || e.getSource() ==buttonSave)
> {
>
> FileOutputStream outputfile;
>
> int returnval = mySaveFile .showSaveDialog(c) ;
> File f =mySaveFile .getSelectedFile() ;
>
> String savedFilePath = f.getPath() ;
> OpenOrSaveFilePath = savedFilePath;
> nameOfTheFile = f.getName();
> runPathforJava = f.getParent() ;
>
>
> System.out.println("The path of the file is: "+ savedFilePath );
> try {
>
> outputfile = new FileOutputStream( savedFilePath );
> //
> byte data[] =tAreaEditor .getText().getBytes();
> outputfile.write(data);
>
> }
>
> catch(Exception excp)
> {
> System.out.println("get the hell out of here");
> }
>
> }
>
> if( e.getSource() == itmCut )
> tAreaEditor.cut();
>
> if( e.getSource() == itmCopy )
> tAreaEditor.copy();
>
> if( e.getSource() == itmPaste )
> tAreaEditor.paste();
>
> if( e.getSource() == itmAbout )
> JOptionPane.showMessageDialog(null, "name: Justin"+
> "\n\nLicense:GNU GPL"+
> "\n\ne-mail: justin...@gmail.com");
>
> }
> }
>
> }
>
> class MyJCreatorTest
> {
> public static void main(String args[])
> {
> MyJCreator m1 = new MyJCreator ();
> m1.setSize(640,450);
> m1.setVisible(true);
> m1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
> }
> }
>
> --------------070907080803030406010805
> Content-Type: image/jpeg
> Content-Transfer-Encoding: base64
> Content-Disposition: inline;
> filename="new2.jpg"
> X-Google-AttachSize: 1250

Justin

unread,
Aug 14, 2006, 3:25:10 PM8/14/06
to Open Projects For All
Reply all
Reply to author
Forward
0 new messages