<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>程序 on 庞玉栋个人博客</title><link>https://pangyd.com/tags/%E7%A8%8B%E5%BA%8F/</link><description>Recent content in 程序 on 庞玉栋个人博客</description><generator>Hugo</generator><language>zh-cn</language><lastBuildDate>Sat, 18 Aug 2018 09:21:28 +0800</lastBuildDate><atom:link href="https://pangyd.com/tags/%E7%A8%8B%E5%BA%8F/index.xml" rel="self" type="application/rss+xml"/><item><title>如何从命令提示符运行Java程序</title><link>https://pangyd.com/post/193-java/</link><pubDate>Sat, 28 Jul 2018 13:51:21 +0800</pubDate><guid>https://pangyd.com/post/193-java/</guid><description>&lt;div class="left" data-reactid=".0.1.0">&lt;div data-reactid=".0.1.0.0">&lt;div class="post" data-reactid=".0.1.0.0.0">&lt;div class="post-main clearfix" data-reactid=".0.1.0.0.0.1">&lt;div class="content-wrapper" id="post_content_wrapper" data-reactid=".0.1.0.0.0.1.1">&lt;div class="content rich" data-reactid=".0.1.0.0.0.1.1.1">&lt;p>&lt;img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='480' height='120'%3E%3Crect width='480' height='120' fill='%230E1012' stroke='%231B1E22'/%3E%3Ctext x='240' y='66' fill='%235C6069' font-family='monospace' font-size='13' text-anchor='middle'%3E%5B%E5%8E%9F%E5%9B%BE%E5%B7%B2%E5%A4%B1%E6%95%88%5D%3C/text%3E%3C/svg%3E">&lt;/p>&lt;p>Java是最常用的编程语言之一。 它也是一个IDE密集型编程语言，与Eclipse紧密集成。 如果您刚开始学习Java，下面是帮助您从命令提示符开始运行Java应用程序（在Windows中）的基本指南。&lt;/p>&lt;p>&lt;span>安装Java开发工具包（JDK）&lt;/span>&lt;/p>&lt;p>在您的计算机上运行Java程序之前，您需要安装一个Java编译器。它附带了Java开发工具包或JDK。它是Java在任何平台上开发的基本工具。JDK与Java运行时环境(或JRE)不一样，如果您在您的机器上使用过Java应用程序，您已经安装了它。&lt;/p>&lt;p>1．从Oracle的网站上下载JDK。确保不要下载到服务器版本的JRE。&lt;/p>&lt;p>&lt;img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='480' height='120'%3E%3Crect width='480' height='120' fill='%230E1012' stroke='%231B1E22'/%3E%3Ctext x='240' y='66' fill='%235C6069' font-family='monospace' font-size='13' text-anchor='middle'%3E%5B%E5%8E%9F%E5%9B%BE%E5%B7%B2%E5%A4%B1%E6%95%88%5D%3C/text%3E%3C/svg%3E">&lt;/p>&lt;p>2．确保您获取了开发工具包的Windows版本。&lt;/p>&lt;p>&lt;img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='480' height='120'%3E%3Crect width='480' height='120' fill='%230E1012' stroke='%231B1E22'/%3E%3Ctext x='240' y='66' fill='%235C6069' font-family='monospace' font-size='13' text-anchor='middle'%3E%5B%E5%8E%9F%E5%9B%BE%E5%B7%B2%E5%A4%B1%E6%95%88%5D%3C/text%3E%3C/svg%3E">&lt;/p>&lt;p>3.正常运行安装程序。&lt;/p>&lt;p>&lt;span>从命令提示符运行Java程序&lt;/span>&lt;/p>&lt;p>1.使用记事本或其他文本编辑器创建一个如下所示的简单Java程序。 请确保以扩展名“.java”而不是“.txt”保存文件。&lt;/p>&lt;p>&lt;img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='480' height='120'%3E%3Crect width='480' height='120' fill='%230E1012' stroke='%231B1E22'/%3E%3Ctext x='240' y='66' fill='%235C6069' font-family='monospace' font-size='13' text-anchor='middle'%3E%5B%E5%8E%9F%E5%9B%BE%E5%B7%B2%E5%A4%B1%E6%95%88%5D%3C/text%3E%3C/svg%3E">&lt;/p>&lt;p>2.从开始菜单打开命令提示符。 您也可以按Win R，然后在运行字段中输入cmd.exe。&lt;/p>&lt;p>&lt;img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='480' height='120'%3E%3Crect width='480' height='120' fill='%230E1012' stroke='%231B1E22'/%3E%3Ctext x='240' y='66' fill='%235C6069' font-family='monospace' font-size='13' text-anchor='middle'%3E%5B%E5%8E%9F%E5%9B%BE%E5%B7%B2%E5%A4%B1%E6%95%88%5D%3C/text%3E%3C/svg%3E">&lt;/p>&lt;p>3.使用cd命令将工作目录更改为包含Java程序的目录。 我保存在我的“脚本”文件夹中，但是您可以将您的文件保存在系统中的任何位置。&lt;/p>&lt;p>&lt;img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='480' height='120'%3E%3Crect width='480' height='120' fill='%230E1012' stroke='%231B1E22'/%3E%3Ctext x='240' y='66' fill='%235C6069' font-family='monospace' font-size='13' text-anchor='middle'%3E%5B%E5%8E%9F%E5%9B%BE%E5%B7%B2%E5%A4%B1%E6%95%88%5D%3C/text%3E%3C/svg%3E">&lt;/p>&lt;p>4．在您的计算机上定位到Java开发工具包(JDK)版本的路径。如果你运行64位Windows，那通常是在“C：\ Program Files \ Java”中。&lt;/p>&lt;p>&lt;img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='480' height='120'%3E%3Crect width='480' height='120' fill='%230E1012' stroke='%231B1E22'/%3E%3Ctext x='240' y='66' fill='%235C6069' font-family='monospace' font-size='13' text-anchor='middle'%3E%5B%E5%8E%9F%E5%9B%BE%E5%B7%B2%E5%A4%B1%E6%95%88%5D%3C/text%3E%3C/svg%3E">&lt;/p>&lt;p>5.使用“set”命令设置JDK的路径，如下所示：&lt;/p>&lt;p>&lt;img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='480' height='120'%3E%3Crect width='480' height='120' fill='%230E1012' stroke='%231B1E22'/%3E%3Ctext x='240' y='66' fill='%235C6069' font-family='monospace' font-size='13' text-anchor='middle'%3E%5B%E5%8E%9F%E5%9B%BE%E5%B7%B2%E5%A4%B1%E6%95%88%5D%3C/text%3E%3C/svg%3E">&lt;/p>&lt;p>您可能需要更改目录路径以反映当前版本的Java。确保您使用的是Java开发工具包(JDK)目录，并指向“bin”文件夹。Java运行时环境(JRE)文件夹也包含一个“bin”文件夹，但不包含Java编译器。如果在编译过程中出现错误，请确保使用正确的目录路径。&lt;/p>&lt;p>6.使用javac命令编译Java程序，如下所示：&lt;/p>&lt;p>&lt;img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='480' height='120'%3E%3Crect width='480' height='120' fill='%230E1012' stroke='%231B1E22'/%3E%3Ctext x='240' y='66' fill='%235C6069' font-family='monospace' font-size='13' text-anchor='middle'%3E%5B%E5%8E%9F%E5%9B%BE%E5%B7%B2%E5%A4%B1%E6%95%88%5D%3C/text%3E%3C/svg%3E">&lt;/p>&lt;p>7.你应该看到什么都没有发生。 但是，如果您使用dir命令，则会在您的目录中以“.class”扩展名结尾注意到一个新文件。 这表示程序已经编译完成。&lt;/p></description></item><item><title>外观设置成所使用的操作平台的外观即程序在哪个平台运行，显示的窗口，对话框将是哪个平台的外观</title><link>https://pangyd.com/post/41/</link><pubDate>Mon, 07 Aug 2017 18:57:57 +0800</pubDate><guid>https://pangyd.com/post/41/</guid><description>&lt;pre lay-lang="Java" class="layui-code" skin="notepad"> //UIManager--界面管理类
			//外观设置成所使用的操作平台的外观
			//即程序在哪个平台运行，显示的窗口，对话框将是哪个平台的外观
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());&lt;/pre></description></item><item><title>转载自【Java编程精选】20个非常有用的Java程序片段</title><link>https://pangyd.com/post/28-java20java/</link><pubDate>Wed, 02 Aug 2017 19:26:36 +0800</pubDate><guid>https://pangyd.com/post/28-java20java/</guid><description>&lt;p>&lt;span>下面是20个非常有用的Java程序片段，希望能对你有用。&lt;strong>内容比较早，有些函数可能过时了，但是总体思路是不错滴，供参考。&lt;/strong>&lt;/span>&lt;/p>&lt;p>&lt;br>&lt;/p>&lt;p>&lt;span>&lt;strong>&lt;span>1、字符串有整型的相互转换&lt;/span>&lt;/strong>&lt;/span>&lt;/p>&lt;pre>&lt;code class="">String a = String.valueOf(&lt;span class="">2&lt;/span>); &amp;nbsp; &lt;span class="">//integer to numeric string&lt;br>&lt;/span>&lt;span class="">int&lt;/span> i = Integer.parseInt(a); &lt;span class="">//numeric string to an int&lt;/span>&lt;/code>&lt;/pre>&lt;p>&lt;span>&lt;strong>&lt;span>2、向文件末尾添加内容&lt;/span>&lt;/strong>&lt;/span>&lt;br>&lt;/p>&lt;p>&lt;span>&lt;/span>&lt;/p>&lt;pre>&lt;code class="">BufferedWriter out = &lt;span class="">null&lt;/span>; &amp;nbsp; &amp;nbsp; &lt;span class="">try&lt;/span> { &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;out = &lt;span class="">new&lt;/span> BufferedWriter(&lt;span class="">new&lt;/span> FileWriter(”filename”, &lt;span class="">true&lt;/span>)); &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;out.write(”aString”); &amp;nbsp; &amp;nbsp; } &lt;span class="">catch&lt;/span> (IOException e) { &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="">// error processing code &amp;nbsp; &amp;nbsp; &lt;br>&lt;/span>} &lt;span class="">finally&lt;/span> { &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="">if&lt;/span> (out != &lt;span class="">null&lt;/span>) { &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;out.close(); &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; }&lt;/code>&lt;/pre>&lt;p>&lt;span>&lt;strong>&lt;span>3、得到当前方法的名字&lt;/span>&lt;/strong>&lt;/span>&lt;/p></description></item></channel></rss>