aspose file tools*
The moose likes Beginning Java and the fly likes Having problems running programs in Textpad Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Having problems running programs in Textpad" Watch "Having problems running programs in Textpad" New topic
Author

Having problems running programs in Textpad

matt van
Greenhorn

Joined: Jan 03, 2007
Posts: 9
I have just installed the latest textpad to my computer and I have been trying to compile programs that my students created using blue J. I have been able to compile the programs, but when I try to Run the programs, the Run Box appears, if I click ok, it gives me the response, the process cannot access the file because it is being used by another process. As well, if I click on Run Java Application, I get the same response. I am trying to run .java files, What am I doing wrong? Somebody please help.

fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11499
    
  16

I'm not sure what you mean by "run .java files". A .java file is nothing more than a text file - it can't be run by anything.

a .java file must be compiled into a .class file with the javac compiler. once you have the .class files, you can run those.

are you using the windows "run program" dialog box? if so, that's wrong - or at least, i've never heard of anyone doing it that way. Usually, once you have compiled the file.java into file.class, from a command line, you do this:
java file

Can you explain more clearly what you are doing?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
matt van
Greenhorn

Joined: Jan 03, 2007
Posts: 9
How do you run the javac compiler? Also, how do a run a program from the command line? I created a simple program from:
public class hello
{
public static void main(String[]args)
{
System.out.println("Hello,World");
}
}

After typing this, I went to tools and then Compile Java, I clicked on this and it did compile, when I tried to run the program again using Run Java Application, I get the response "the process cannot access the file because it is being used by another process".
Also, when I do compile the file hello, it does not create a .class file.
I hope this makes sense, sorry if there is confusion.

Thank you for the help!
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by matt van:
How do you run the javac compiler? Also, how do a run a program from the command line? ...

See this Hello World tutorial (for Windows), which provides a step-by-step process for using the javac and java commands.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
matt van
Greenhorn

Joined: Jan 03, 2007
Posts: 9
Thank you, I will take a look.
Unnar Björnsson
Ranch Hand

Joined: Apr 30, 2005
Posts: 164
If the compiler does not create a .class file, it did not compile your code.
Are you sure there are no errors in your compiler output?
matt van
Greenhorn

Joined: Jan 03, 2007
Posts: 9
Shouldn't I be able to run a program from Textpad instead of having to go to the command line? If so, what do I need to do in Textpad to get the program to work, like helloworld.
Thanks
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9053
    
  12
After you compile (using Tools --> Compile or Ctrl-1) your .java file, you should see a .class file right next to it with the same name. In other words, if you compile HelloWorld.java, you should find a HelloWorld.class file in the same directory. (I think it is there or otherwise you would be getting a different error when you tried to run the application --
java.lang.NoClassDefFoundError: HelloWorld
Exception in thread "main"
Tool completed with exit code 1

To run the application you can use Tools --> Run Java Application (or Ctrl-2). I have never run into the error you describe in all the years I have used TextPad. In fact, I can't even make it produce that error when I open the .java and/or .class file in another application. [Tools --> Run ... is for something else entirely.]

So despite the appearance that you are using TextPad Tools properly, I am unable to help you resolve your issue.

Whatever editor the students are using (BlueJ, IntelliJ, Eclipse, TextPad, NotePad, DOS edit) they should send you their .java file in plain ascii text. You can compile their .java file with whatever method you choose (TextPad, command line or whatever) and likewise run the application after it is compiled using TextPad, command line or whatever. No problem. We do that all the time in the CattleDrive course here at JavaRanch. Make sure they are not sending you the .class file.
[ January 04, 2007: Message edited by: Marilyn de Queiroz ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
matt van
Greenhorn

Joined: Jan 03, 2007
Posts: 9
I have tried running the program from Textpad and it does not create a .class file in the window to the left of the editor that shows the Command Results. It does create a .class folder in the directory that I am trying to run it out of, but this still does not allow me to see the output. Is it possible that this is not working because I do not have the correct directory set up for the files, meaning (am I trying to run this from a folder that is not attached to the correct directory that textpad is held in) Does this make sense?
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9053
    
  12
You should not see the .class file in the result window. If it compiles successfully, you may see
"Tool completed successfully"
in the result window, but TextPad will return to the .java file that you compiled.

After you successfully compile the .java file into a .class file (which you can see in the same directory as the .java file by using Windows Explorer), you should be able to "Run Java Application" and see some results in the result window (if it prints something using System.out.println).

The .java file should not be in the same directory that TextPad is installed in. I usually keep my .java files in a directory named "java" (i.e. C:\java\)

Double check that Configure --> Preferences --> Tools --> Run Java Application --> "Capture output" is checked.
Unnar Björnsson
Ranch Hand

Joined: Apr 30, 2005
Posts: 164
After you compile your code, open the command results window, what does it say?
It should say "Tool completed successfully"
matt van
Greenhorn

Joined: Jan 03, 2007
Posts: 9
Sorry about the last post [removed by mw], it does say in the command results window, "Tool completed successfully". I then try to run java application and it continues to give me the same result of "the process cannot access the file because it is being used by another process". I did go to Configure and preferences, but this still did not allow me to see the results. Thank you for all the help, please, if you have any more suggestions.
[ January 05, 2007: Message edited by: marc weber ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by matt van:
Sorry about the last post [removed by mw]...

You can edit/delete your own posts by clicking on the paper/pencil icon. (Note to the curious: This was nothing "bad." It just looks like it got posted in mid-composition.)

So are you able to compile and run from the command line? If so, then I think we should move this thread to the IDE forum -- but only after we've verified that Java is correctly installed to work from the command line.
Unnar Björnsson
Ranch Hand

Joined: Apr 30, 2005
Posts: 164
Have you tried killing all non-essential processes via task manager?
matt van
Greenhorn

Joined: Jan 03, 2007
Posts: 9
For the last two messages, I tried to run from the command line and it does not seem to work, probably because I am not sure exactly how to do it. Do you have any suggestions?
To the second message, what would I be looking for to kill the non-essential processes in task manager. Sorry this is taking so long for me to figure out and thank you for continuing to try and help me.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by matt van:
... I tried to run from the command line and it does not seem to work...

Tell us exactly what steps you followed (starting from where you saved the .java file, and exactly what commands you entered), and where the problem occurred, including any error messages.

If you can copy and paste your command prompt session, that would be helpful.
matt van
Greenhorn

Joined: Jan 03, 2007
Posts: 9
The program hello.java is being saved in my C drive at C:\Documents and Settings\Settings\Matt Van\Desktop\Java Project Assignments\hello.java, after I compile the program from Tools using Compile Java, it shows command result after I click on Compile Java, but nothing is inside this file. I then click on Run Java Application and it gives me the result from file C:\Documents and Settings\Settings\Matt Van\Desktop\Java Project Assignments\tp06b363.bat, from this prompt it tells me "the process cannot access the file because it is being used by another process" and never gives me the output using Textpad. I hope this helps. I am not sure how to use the command line correctly.
[ January 11, 2007: Message edited by: matt van ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Close TextPad and follow the Hello World tutorial (for Windows). Tell us how these steps work for you.
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
Originally posted by Fred Rosenberger:
Can you explain more clearly what you are doing?

He is using Textpad. I started using it while reading Core Java by Cay S. Horstmann. Dr. Horstmann holds:
  • Ph.D. Mathematics, University of Michigan, Ann Arbor, 1987
  • Diplom Mathematics and Computer Science, Christian Albrechts Universit�t Kiel, Germany, 1981
  • M.S. Computer Science, Syracuse University, 1980
  • Cover citation as author on: Core Java - Sun Microsystems Press 1996 - 2005 (7 editions)
  • A pretty cool website.

  • Textpad is useful when just getting the job done is work enough, the last thing you need is to waste time having to learn yet another computer application. Your experience with other tools should be relevant to each new application, making it possible to sit down and use that new application right away.


    "The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
    Nicholas Jordan
    Ranch Hand

    Joined: Sep 17, 2006
    Posts: 1282
    Originally posted by marc weber:
    Close TextPad and follow the Hello World tutorial (for Windows). Tell us how these steps work for you.

    Textpad will compile Java from a menu item within the application, compiling whatever source.java code file is open in the window.
    marc weber
    Sheriff

    Joined: Aug 31, 2004
    Posts: 11343

    Originally posted by Nicholas Jordan:
    Textpad will compile Java from a menu item within the application...

    It should, but in this case it seems to be hanging on something. I think Textpad basically just uses a .bat file to issue the commands. If we can test the process by manually typing the commands, maybe we'll see what the problem is.
    Nicholas Jordan
    Ranch Hand

    Joined: Sep 17, 2006
    Posts: 1282
    Originally posted by marc weber:

    It should, but in this case it seems to be hanging on something. I think Textpad basically just uses a .bat file to issue the commands. If we can test the process by manually typing the commands, maybe we'll see what the problem is.

    If so, I had this problem or something similar and fixed it by removing the compile java command using the delete command, then used the add java compile commnand to replace it. The command began working again.

    Textpad does seem to use batch files, it clutters up the directory with these. I also experienced a system hang due to a setting noted as capture output and the way this command works in conjunction with the batch files.

    Something along this line of thought is noted in the help files.
    [ January 12, 2007: Message edited by: Nicholas Jordan ]
    matt van
    Greenhorn

    Joined: Jan 03, 2007
    Posts: 9
    I just wanted to thank everyone for their help. I am not sure exactly what the problem was, but I believe it was an internal problem. I tried to open my cmd prompt from the run command and I was getting an error that the program was already being used. If I typed in command, it would bring me to the command prompt, but would not allow me to see the dir. I called text support for my laptop and they could not figure it out. I ended up saving my documents and using the recovery disk. I downloaded textpad and now the program works fine. Sorry for all of the confusion.
    marc weber
    Sheriff

    Joined: Aug 31, 2004
    Posts: 11343

    Originally posted by matt van:
    ...I ended up saving my documents and using the recovery disk. I downloaded textpad and now the program works fine. Sorry for all of the confusion...

    Wow, I'm glad you got it worked out!
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Having problems running programs in Textpad