2,安装
3,启动一个cmd窗口,敲入javac 如果显示不是命令的话,把环境变量配置一下。
计算机⇒属性⇒系统保护⇒高级⇒环境变量⇒系统变量⇒path
假如的你的jdk安装目录为E:\jdk就把E:\jdk\bin这个地址复制到path里面去,注意后面加个分号()
4,再次运行javac 会显示一些内容,恭喜你搭建好了。
方法如下:
找到菜单 window → Show View → Servers,打开Servers视图标签,部署的Tomcat 服务
在这个服务上右击,选择“Add Deployment”
在新打开的对话框中,有一个Project项,选择要部署的项目
点击“Finish”完成部署
这样项目就部署到Tomcat里面去了
以前写的,照贴了。。。服务器端:import java.awt.*\x0d\x0aimport java.awt.event.WindowAdapter\x0d\x0aimport java.awt.event.WindowEvent\x0d\x0aimport java.io.*\x0d\x0aimport java.net.*/*6、 采用UDP协议,编写一个Java网络应用程序,该应用分服务器端程序和客户端程序两部分。\x0d\x0a* 客户端指定一个服务器上的文件名,让服务器发回该文件的内容,或者提示文件不存在。\x0d\x0a* (20分)(服务端程序和客户端程序分别命名为Server.java和Client.java)*/\x0d\x0apublic class N4BT6 extends Frame\x0d\x0a{\x0d\x0aDatagramSocket socket \x0d\x0aDatagramPacket packet byte[] buf \x0d\x0aFile file \x0d\x0aFileInputStream input\x0d\x0aString message = "该文件不存在"\x0d\x0aTextArea text\x0d\x0apublic N4BT6(String title)\x0d\x0a{\x0d\x0asuper(title)\x0d\x0atext = new TextArea(6,4)\x0d\x0aadd(text)\x0d\x0asetSize(400, 300)\x0d\x0asetVisible(true)\x0d\x0aaddWindowListener(new WindowAdapter()\x0d\x0a{\x0d\x0apublic void windowClosing(WindowEvent e)\x0d\x0a{\x0d\x0adispose()\x0d\x0a}\x0d\x0a})\x0d\x0a\x0d\x0abuf = new byte[1024]\x0d\x0atry\x0d\x0a{\x0d\x0asocket = new DatagramSocket(1230)\x0d\x0apacket = new DatagramPacket(buf, buf.length)\x0d\x0asocket.receive(packet)\x0d\x0afile = new File(new String(packet.getData()))\x0d\x0asocket = new DatagramSocket()\x0d\x0a} \x0d\x0acatch (Exception e)\x0d\x0a{e.printStackTrace()\x0d\x0a}\x0d\x0a\x0d\x0aif(file.exists())\x0d\x0a{\x0d\x0atry\x0d\x0a{\x0d\x0abuf = new byte[(int)file.length()]\x0d\x0apacket = new DatagramPacket(buf,buf.length,InetAddress.getLocalHost(),1234)\x0d\x0ainput = new FileInputStream(file)\x0d\x0ainput.read(buf)\x0d\x0asocket.send(packet)\x0d\x0a}\x0d\x0acatch (IOException e) \x0d\x0a{\x0d\x0ae.printStackTrace()\x0d\x0a}\x0d\x0a}\x0d\x0aelse\x0d\x0a{\x0d\x0atry\x0d\x0a{\x0d\x0apacket = new DatagramPacket(message.getBytes(),message.getBytes().length,\x0d\x0aInetAddress.getLocalHost(),1234)\x0d\x0asocket.send(packet)\x0d\x0a}\x0d\x0acatch (Exception e) \x0d\x0a{\x0d\x0ae.printStackTrace()\x0d\x0a}\x0d\x0a}\x0d\x0a\x0d\x0a}\x0d\x0apublic static void main(String[] args)\x0d\x0a{\x0d\x0anew N4BT6("Server")\x0d\x0a}\x0d\x0a}\x0d\x0a客户端:import java.awt.*\x0d\x0aimport java.awt.event.*\x0d\x0aimport java.net.DatagramPacket\x0d\x0aimport java.net.DatagramSocket\x0d\x0aimport java.net.InetAddresspublic class N4BT6_2 extends Frame\x0d\x0a{\x0d\x0aTextArea text\x0d\x0aString message = "Q.txt"\x0d\x0aDatagramSocket socket \x0d\x0aDatagramPacket packet\x0d\x0abyte[] buf\x0d\x0apublic N4BT6_2(String title)\x0d\x0a{\x0d\x0asuper(title)\x0d\x0atext = new TextArea(6,4)\x0d\x0aadd(text)\x0d\x0asetSize(400, 300)\x0d\x0asetVisible(true)\x0d\x0aaddWindowListener(new WindowAdapter()\x0d\x0a{\x0d\x0apublic void windowClosing(WindowEvent e)\x0d\x0a{\x0d\x0adispose()\x0d\x0a}\x0d\x0a})\x0d\x0atry\x0d\x0a{\x0d\x0a\x0d\x0asocket = new DatagramSocket()\x0d\x0apacket = new DatagramPacket(message.getBytes(),message.getBytes().length,\x0d\x0aInetAddress.getLocalHost(),1230)\x0d\x0asocket.send(packet)\x0d\x0a}\x0d\x0acatch (Exception e) \x0d\x0a{\x0d\x0ae.printStackTrace()\x0d\x0a}\x0d\x0a\x0d\x0atry\x0d\x0a{\x0d\x0abuf = new byte[1024]\x0d\x0asocket = new DatagramSocket(1234)\x0d\x0apacket = new DatagramPacket(buf,buf.length)\x0d\x0asocket.receive(packet)\x0d\x0atext.append(new String(buf))\x0d\x0a}\x0d\x0acatch (Exception e) \x0d\x0a{\x0d\x0ae.printStackTrace()\x0d\x0a}\x0d\x0a}\x0d\x0apublic static void main(String[] args)\x0d\x0a{\x0d\x0anew N4BT6_2("Client")\x0d\x0a}\x0d\x0a}欢迎分享,转载请注明来源:夏雨云
评论列表(0条)