473,545 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Running java program

lifeisgreat20009
70 New Member
This is what i am getting on running the program........ .

C:\PROGRA~1\Jav a\JDK15~1.0\bin >javac Editor.java
Note: Editor.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecati on for details.


I did run the program like this after compiling it using javac command........ .

I get this........

C:\PROGRA~1\Jav a\JDK15~1.0\bin >Editor
'Editor' is not recognized as an internal or external command,
operable program or batch file.



On giving Editor.java as the command the file itself gets opened and not a new text editor that i want........... .....



Below is my code with no errors but its not running........ .


Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import java.io.*;
  4.  
  5. class Editor extends Frame implements ActionListener
  6. {
  7. TextArea textArea = new TextArea();
  8.  
  9. //Set up the menu on the default CTOR.
  10. Editor()
  11. {
  12. super("Text AWT Editor");
  13. setLayout(new BorderLayout());
  14. add("Center", textArea);
  15. Menu menu = new Menu("File");
  16. menu.add(makeMenuItem("Open"));
  17. menu.add(makeMenuItem("Save"));
  18. menu.add(makeMenuItem("Quit"));
  19. MenuBar menuBar = new MenuBar();
  20. menuBar.add(menu);
  21. setMenuBar(menuBar);
  22. pack();
  23. }
  24. private MenuItem makeMenuItem(String name)
  25. {
  26. MenuItem m = new MenuItem(name);
  27. m.addActionListener(this);
  28. return m;
  29. }
  30. public static void main(String[] s)
  31. {
  32. new Editor().show();
  33. }
  34. public void actionPerformed(ActionEvent e)
  35. {
  36. String command = e.getActionCommand();
  37. if (command.equals("Quit"))
  38. dispose();
  39. else if (command.equals("Open"))
  40. openFile();
  41. else if (command.equals("Save"))
  42. saveFile();
  43. }
  44. private void openFile()
  45. {
  46. //Show the Open File dialog box to the user.
  47. FileDialog fd = new FileDialog(this, "Open File", FileDialog.LOAD);
  48. fd.show();
  49.  
  50. //Get the file path.
  51. StringBuffer sbPath = new StringBuffer(fd.getDirectory());
  52. sbPath.append("\\");
  53. String fileName = fd.getFile();
  54.  
  55. //Cancel if null:
  56. if (fileName == null)
  57. {
  58. return;
  59. }
  60. else sbPath.append(fileName);
  61.  
  62. // Open and fill the input stream; paint the TextArea.
  63. try
  64. {
  65. FileInputStream fs = new FileInputStream(sbPath.ToString());
  66. byte[] data = new byte [ sbPath.length() ];
  67. fs.read(data);
  68. textArea.setText(new String(data));
  69. }
  70. catch (IOException e)
  71. {
  72. textArea.setText(e.toString());
  73. }
  74. }
  75.  
  76. private void saveFile()
  77. {
  78. try
  79. {
  80. // Show the dialog box to the user.
  81. FileDialog fd = new FileDialog(this, "Save File", FileDialog.SAVE);
  82. fd.show();
  83.  
  84. //Get the path and file name.
  85. StringBuffer sbPath = new StringBuffer(fd.getDirectory());
  86. sbPath.append("\\");
  87. // Get the file name to create:
  88. sbPath.append(fd.getFile());
  89. FileOutputStream fo = new FileOutputStream(sbPath.ToString());
  90.  
  91. // Parse the data: 
  92. String strdata = textArea.getText();
  93. byte[] data = new byte [strdata.length()];
  94. for (int idx = 0; idx < strdata.length(); idx++)
  95. {
  96. data[idx] = (byte)strdata.charAt(idx);
  97. }
  98. // Write the array to the file.
  99. fo.write(data);
  100. }
  101. catch (IOException ex)
  102. {
  103. textArea.setText(ex.toString());
  104. }
  105. }
  106. }
  107.  
  108.  
Nov 1 '07 #1
4 2113
r035198x
13,262 MVP
The
Expand|Select|Wrap|Line Numbers
  1. javac
command does not run the program. It compiles the .java file into a .class file.
To run the .class file, run the
Expand|Select|Wrap|Line Numbers
  1.  java 
command

That deprecated warning thing means exactly what it says there.
Nov 1 '07 #2
lifeisgreat20009
70 New Member
I did run the program like this after compiling it using javac command........ .

I get this........

C:\PROGRA~1\Jav a\JDK15~1.0\bin >Editor
'Editor' is not recognized as an internal or external command,
operable program or batch file.
Nov 1 '07 #3
r035198x
13,262 MVP
Do not start many threads on the same topic. Use one thread for one problem.

Type
Expand|Select|Wrap|Line Numbers
  1.  java Editor
at the command after compiling to run the program
Nov 1 '07 #4
lifeisgreat20009
70 New Member
Ok Sorry.......... ...
I will remember that........... ...
And thanks a lot............ ......
Thank you sooooooooooooo much........... ....

Bye............ .
take care...........
Nov 1 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1816
by: Hal Vaughan | last post by:
While experimenting with System.getProperty() and System.setProperty(), I've noticed that I can change properties, but those changes do not last once the JVM they're modified in terminates. I experimented with java.class.path to see if I could extend it while a class was running (I think I read about this somewhere, but I can't find it...
2
3970
by: Peter Bassett | last post by:
I haven't programmed in Java for awhile and forgot how to get this to work. I have a program ListFiles developed in c:\java which lists every .JPG and ..GIF file in a folder. It works fine running from that folder. It takes 1 argument, the pathname, so a command could be "java ListFiles ." But if I try to run it from another folder, using...
2
4941
by: parthan | last post by:
We are running our c++ program, which uses JNI, as Windows services. Program is getting CLASSPATH env variable correctly and also initializes JVM successfully. After initializing JVM, programs makes a JNI call FindClass() for getting java class.But FindClass method returns NULL even though java class exists in the CLASSPATH. Same program...
10
5135
by: jon | last post by:
I am a beginner C programmer, this is actually my first programming lanugage, besides html, cgi, and javascript. I am looking for a way to make an .exe file, or a copy of my own file. I have tried writing a file, compling it, and reading it in a notepad, then writing a program to write it again, but i have had no luck. I assure you i'm not...
4
3969
by: nishi57 | last post by:
I hope I can get some help regarding this issue, which has been going on for a while. I have a desktop user who is having problem running "Stored Procedures". The DB2 Connect application works fine but when he runs the stored procedure, he gets the following error message. "SYSPROC".CSGCSB54 - Run started. Data returned in result sets is...
1
7541
Nepomuk
by: Nepomuk | last post by:
Hi! I'm trying to run an external Program with Process p = Runtime.getRuntime().exec("/bin/sh -c \"/bin/gzip -c /home/user/workspace/TarGz/pics.tar > pics.tar.gz\""); CleanStream cleanError = new CleanStream(p.getErrorStream(), "ERROR"); CleanStream cleanOutput = new CleanStream(p.getInputStream(), "OUTPUT"); clearError.start();...
0
1188
by: shaileshkumar | last post by:
hi, iam unable to run my applications in netbeans4.1. problem may be due to JVM or port numbers conflict. i did not intentionally change any port numbers . please guide me accordingly. iam pasting the error report ( thanks in advance) -------------------------------------------------------------------------
3
3686
by: WP | last post by:
Hello, I have a very simple script (or would you call it a batch file?) with the following content: connect to mydb2; DROP TABLE staff_employee_address; DROP TABLE staff_employee_address_telephone; DROP TABLE staff_employee; DROP TABLE staff; commit; terminate;
0
2429
by: Siyodia | last post by:
This is a java program which i need to run facing compilation error Its consuming a third party web service method I have the supported files(folder) which contain necessary class files org/apache/axis The following is what i need to do but am unable to do ...
0
7473
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7406
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7660
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7761
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5976
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3457
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1888
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1020
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
709
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.