Posted by: raghs | Tuesday, July 24, 2007

how to deal with java programs in EditPlus

This post may help you to deal with Java Programs in the EditPlus – a famous editor for many different type of files (for example, .java, .css, .html, .sql, .txt etc).

 One more similar editor is TextPad, which can directly deal with Java applications as its taking the Java Compiler by default from the installed location in the machine it is running.  Thats one advantage with that.

What exactly do i mean to say “dealing with Java applications”? Does it mean typing the source code? Absolutely NOT! That does not require any special settings and you can start typing as you would with any other file. I mean to say, “Compiling” and “Running” of Java applications.

In EditPlus, we cannot direclty deal with Java Applications and they need some sort of settings to do that. Lets see them one by one.

1. Options to set for Compilation (”javac”):

Go to “Tools” Menu -> and click on “Configure User Tools…” option.

 Click on the individual images to see the full-size screenshots if it does not display the image in full. 

Every image has the required description and explanation for the step.

Image1:  Clicking on “Configure User Tools…” Option in the “Tools” Menu

1_Tools Menu-ConfigureUserTools

It will open a new dialog box where in you can enter your details to configure for the tools.

Image2: The Initial Groups and Tools Window dialog box

2_Empty Groups and Tools Items Window

Image3: Clicking on “Add Tool” button in the Dialog box

3_click on AddTool

Image4: The Initial window on “Add Program”

4_InitialWindowOnAddProgram

Image5: Configuring “javac” for compilation – step 1

5_CompileJavaProgram-1

Image6: Configuring “javac” for compilation – step 2

5_CompileJavaProgram-2

Image7: Verifying the “javac” tool added in the “Tools” Menu

6_VerifyCompileJavaProgramInToolsMenu

2. Options to set for Execution (”java”) :

Image8: Configuring “java” for execution

7_Configure java

Image9: Verifying the “java” tool added in the “Tools” Menu

8_VerifyRunJavaProgramInToolsMenu

Image10: Compiling a Java Program

9_Compile Java Program

Image11: Running (Executing) a Java Program by giving the command line arguments

10_Run Java Program with cmd line args

Image12: Output of running the Java Program with command line arguments

11_Run Java Program with cmd line args-output

Image13: Output of running the Java Program without any command line arguments

12_Run Java Program with no cmd line args-output

Hope the series of screenshots helped you configure and run a Java Program in EditPlus.

I have blogged this steps as i have seen this in one of the threads in JavaRanch. But still, i would suggest you to just proceed with Notepad and the normal Command Window if you are in the beginning stage because the ordinary plain text editor like Notepad will help you improve your language syntax by not having any support for syntax highlighting!

It would be so nice if you could please share your feedbacks and suggestions if any for the improvement of the material.


Responses

  1. Is there a way to debug the java programs step by step using breaks etc.. using EditPlus

  2. @ formeoct,

    Yes there are ways. But its possible only in IDEs (Integrated Development Environment) which could get the complete Java Runtime Environment for the program and facilititate the user to debug.

    Whereas the Editplus is just an enriched editor that adds a little bit of value by having syntax highlighting, ability to compile and run the programs etc.,

    You may please consider using the IDEs like Netbeans, Eclipse etc for the debugging purposes.

  3. its very good and simple to understand thanks
    raghs

  4. I have Editplus latest version v 3.0 and it doesnt have any checkbox like “prompt for arguements”.So how should i run my java programs which has invovle values taken from users. Please help me out.

  5. I have agin faced another problem with it how to compile a package(User defined)

  6. @krishnaveni,

    welcome here! :)

    //its very good and simple to understand thanks
    raghs//

    am glad that you found it very useful. thank you krishnaveni! pleasure is mine :)

  7. @Aparajitha,

    welcome here!

    //I have Editplus latest version v 3.0 and it doesnt have any checkbox like “prompt for arguements”.So how should i run my java programs which has invovle values taken from users. Please help me out//

    no idea.. i used v2.12.. it should have all.. have u followed the procedures? please let me know how u r doing it?

  8. @Aparajitha,

    //I have agin faced another problem with it how to compile a package(User defined)//

    I don’t think you have to do something explicit or special. The same helps you to compile the java classes belonging to user defined packages.

    Just try doing or let me know how you do it.. so that i can try to help you further!

    Thanks for dropping and commenting!

  9. I have the similar problem as Aparajitha regarding user packages.
    I’m not able to run the class which is compiled using edit plus, ‘coz it runs the class by simulating the following comand:

    java mypack/MyProg –which is not valid acc to java

    it should use the command in the following way:

    java mypack.MyProg

  10. thanks a lot..

    It was quite well explained .

    Nitin

  11. how to compile java code that requires certain library files for compilation

  12. Hello everybody, my name is Damion, and I’m glad to join your conmunity,
    and wish to assit as far as possible.

  13. @Sathish and Aparajitha,

    Thank you. That’s a valid point and i have not tested that basic but important feature! :(

    After your replies, i just tried working out. But i could not achieve it directly. Instead i can do it through a work around.

    I have tried in both EditPlus 2.2 and the latest version 3.3.

    In EditPlus 2.2
    ==========
    I am able to compile the classes in user defined packages without any hassles.
    Only problem is when running a java program. I had given the package name in the configuration window (in your case, i had given the following:

    1. “mypack.$(FileNameNoExt)” in the “Argument:” option
    2. “” in the “Initial directory:” option.

    It worked fine. I know this is difficult as you have to keep changing the aforesaid 2 options for every program with a different package structure.

    In EditPlus 3
    =========
    I think it works in a very different way. I can’t even compile the classes with and without user defined packages. I have to try a bit more and shall get back to you.

    Hope this may help atleast to certain extent. There is a way with a bit overhead.

    Thank you guys! Glad that you found this post to be useful.

    Cheers! :)

  14. ouch.. in the prev reply, the option was misinterpreted as part of html tag i guess.. as i had given it inside the angle brackets..

    In Editplus 2.2 configuration,

    2. “The parent directory of the mypack directory” was given in the “Initial directory:” option.

    For example, if you had placed the ‘mypack’ folder inside “C:\JavaPgms\Userdefined\mypack” you need to give the
    “C:\JavaPgms\Userdefined” in the “Initial directory:” option.

  15. @Nitin,

    Welcome here. Its my pleasure and i am glad that you found this post to be useful :)

  16. @Shweta,

    Welcome here. :)

    //how to compile java code that requires certain library files for compilation//

    I guess it can very well be achieved by giving the options for “java” and “javac” commands. For example, if you need to mention the .jar files for compiling,

    “javac YourPgm.java -classpath XYZ.jar” OR

    “javac YourPgm.java -cp XYZ.jar”

    The XYZ.jar have to be specified with its location where it is present. Try out and let me know.

    Thanks for dropping by!

  17. @DamionKutaeff,

    Welcome here. Thanks for the offering! :)

  18. when i compile prog it giive me error that..

    error: cannot read: first.java
    and aftter running program….the output

    ———- Run Java Program ———-
    java.lang.NoClassDefFoundError: first
    Exception in thread “main”
    Output completed (0 sec consumed)

  19. @kuldeep,

    welcome here!

    By looking at the error you get at compilation time itself it is evident that your compilation was not successful at all.

    From which directory you are running your program? It does make sense and with which only the JRE searches for the .class file.

    Is your class under any specific explicit package?

  20. Well Liked it what you all have discussed above.. Long back I have used Edit plus to compile and run my Java programs.. Today I was just remembering all those stuffs.. But was king of forgotten.. I saw this website and it was very helpfull… Nice Job Guys…

  21. @Sumit Kumar,

    Welcome here! Thanks for the compliments. I am glad that you found this post useful! :)

  22. Good work dude!!!It was very useful and easy too

    one prob

    Compiles fine but on runtime it gives an error
    java.lang.NoClassDefFoundError
    Exception in thread “main”
    Output completed (0 sec consumed)

    plz help me out

  23. @Suchit,

    Welcome here!

    //Good work dude!!!It was very useful and easy too//

    Glad that you found it useful!

    //java.lang.NoClassDefFoundError
    Exception in thread “main”//

    How are you actually executing it? It is all with the path/folder Editplus searches for the .class file. Just check one of the previous comments where i have clearly explained the steps!!

    Sorry for the delayed response!!

    If you still got stuck, let me know! Good luck :)

  24. @Suchit,

    you’re getting no classfound because (as Raghs mentioned), java can not find the .class file. In order to get rid of this, when configuring your user tool, in the text box called Initial Directory, ensure that you have “$(FileDir)” for both the compile and run time commands.

  25. hii evryone…….

    thanks for maintaining such an informative blog…!

    well sachin n raghs…… am facing the same problem as suchit……….

    pls guys….help out………

    not able to run any program……

    ‘coz wen am tryin to run any java program,the following is being displayed

    java.lang.NoClassDefFoundError
    Exception in thread “main”
    Output completed (0 sec consumed)

  26. @raafiya ,

    Welcome here and thank you for the nice words!!

    //java.lang.NoClassDefFoundError
    Exception in thread “main”
    Output completed (0 sec consumed)//

    This basically comes when the .class file is not being able to be picked up! Can you please check your settings on running the java application? It would be great. If not, send a mail to me with the screenshot of your settings.

  27. @sachin,

    Welcome here and thank you for the descriptions ;)

  28. actually am gettin the same error msg wid command prompt also….!!!!!

  29. @raafiya,

    kindly send a mail with screenshots with settings you have. also give some more details on your directory structure of your programs!

  30. Great to start with….Thanks Raghs…

    @Rafiya… as Raghs has suggested you to check your settings.. You might check this site to find out what he means….

    http://labs.cms.gre.ac.uk/java/editplus.asp

  31. @sanjib,

    Welcome here! Thank you very much for the comments Sanjib! :)

  32. hi
    i m getting problems with classes within same package..there r 3 classes “protection”,”derived” n “samepackage” within “package1″.

    “protection” is declared public,”derived” is subclass of “protection”.

    problem is “samepackage” cant access “protection” althought i used object of it..
    plz help…

  33. and derived also can not access “protection n i get errer….

    ———- Compile Java Source ———-
    derived.java:2: cannot find symbol
    symbol: class protection
    class derived extends protection
    ^
    derived.java:7: cannot find symbol
    symbol : variable n
    location: class package1.derived
    System.out.println(”n=”+n);
    ^
    derived.java:9: cannot find symbol
    symbol : variable n_pub
    location: class package1.derived
    System.out.println(”n_pub=”+n_pub);
    ^
    derived.java:10: cannot find symbol
    symbol : variable n_pro
    location: class package1.derived
    System.out.println(”n_pro=”+n_pro);
    ^
    4 errors

    Output completed (0 sec consumed)

  34. @tanvi,

    welcome here.

    Where exactly your .class files are getting stored? That means, which location/directory you are storing the compiled .class files of all these source files?

  35. I have java setup with editplus but anytime i try to run code with Scanner in it, it just freezes and i have to close java from the task manager. I can run the code in other apps and it works fine. what am i doing wrong??

  36. @Muhammed,

    Thanks for dropping in and welcome here!

    //I have java setup with editplus but anytime i try to run code with Scanner in it, it just freezes and i have to close java from the task manager.//

    I presume you use Java 6.0 with Editplus. To be frank, I have NOT tried it out yet.

    But I guess there is no proper leverage between the console/terminal and the client (Editplus). Just try it out by using appropriate flush() and/or close() methods.

  37. thanks for your info…it was useful for me a lot

  38. @sahul vetcha,

    Welcome here and thanks for dropping by!

    //thanks for your info…it was useful for me a lot//

    I am glad that you found it useful :)

  39. Hey, Thanks for a detailed tutorial.
    Great work. I really appreciate it.
    Thanks again.

  40. This post of yours was really useful to help me compile and run java pgms in EditPlus.
    Thank you so much!
    It was all well explained.
    Keep it up!

  41. hi raghs,

    your tips were very helpful !!!!!!!!!!!!

    but i am unable to find “prompt for arguments” option in order to run the program using command line arguments where do i find it???????
    please help me
    thanks,
    raghu

  42. hey thanks for all the useful info…but i still have an unusual problem….unlike everybody else im getting no errors at all!!!…no matter what i do, i wont get errors…?…. can anyone tell me what the problem is?

  43. Hi there,

    I have set up the edit plus according to the steps explained above.
    But it is not compiling and creating my program when I compile it.
    Please kindly explain me how to set the path to store the .class files.
    Because when I compile it no class is generating in the source file directory. And when I run the program its giving NoClassDefinationFound exception.

  44. Hey Please Ignore my previous post. Now I can compile my java programs and see their output in edit plus itself.

    Thanks for your help..

  45. @sudheer,

    glad you find it useful and resolved. Thanks for dropping by!

  46. even tough followed the same settings am getting
    Exception in thread “main” in edit plus plz help me

  47. Very well done! :)

  48. My congratulations!
    The instructions are well-organised and easy-to-follow.
    Do u know how to get an output window in editplus when compiling and runnig the code how it is possible to see an output in a separate window for example when we use applet code, or code which requests to enter the text and click the button etc so that we will see these buttons and all program in a separate window.
    I will appreciate any help.
    I am looking forward to hear from you.
    Kind Regards,
    Emily


Leave a response

Your response:

Categories