<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Compile and run Java program in package from command line	</title>
	<atom:link href="https://www.jitendrazaa.com/blog/java/compile-and-run-java-program-in-package-from-command-line/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.jitendrazaa.com/blog/java/compile-and-run-java-program-in-package-from-command-line/</link>
	<description>AI, Salesforce, ServiceNow &#38; Enterprise Tech Guides</description>
	<lastBuildDate>Wed, 22 Jun 2022 11:26:23 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>
		By: subbaraman ramaswamy		</title>
		<link>https://www.jitendrazaa.com/blog/java/compile-and-run-java-program-in-package-from-command-line/#comment-46563</link>

		<dc:creator><![CDATA[subbaraman ramaswamy]]></dc:creator>
		<pubDate>Wed, 22 Jun 2022 11:26:23 +0000</pubDate>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=1984#comment-46563</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.jitendrazaa.com/blog/java/compile-and-run-java-program-in-package-from-command-line/#comment-5762&quot;&gt;Ngo Alalibo&lt;/a&gt;.

How to download the java compiler with jdk and jre having same versions and to run java programs in command line by setting the path?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.jitendrazaa.com/blog/java/compile-and-run-java-program-in-package-from-command-line/#comment-5762">Ngo Alalibo</a>.</p>
<p>How to download the java compiler with jdk and jre having same versions and to run java programs in command line by setting the path?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: EPAPHRAS		</title>
		<link>https://www.jitendrazaa.com/blog/java/compile-and-run-java-program-in-package-from-command-line/#comment-37922</link>

		<dc:creator><![CDATA[EPAPHRAS]]></dc:creator>
		<pubDate>Mon, 30 May 2022 22:21:16 +0000</pubDate>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=1984#comment-37922</guid>

					<description><![CDATA[Thanks a lot to ALL TEAM, this tutorial help me to understand all I want.]]></description>
			<content:encoded><![CDATA[<p>Thanks a lot to ALL TEAM, this tutorial help me to understand all I want.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Michael Lueck		</title>
		<link>https://www.jitendrazaa.com/blog/java/compile-and-run-java-program-in-package-from-command-line/#comment-7175</link>

		<dc:creator><![CDATA[Michael Lueck]]></dc:creator>
		<pubDate>Fri, 09 Jul 2021 02:59:49 +0000</pubDate>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=1984#comment-7175</guid>

					<description><![CDATA[Thank you for the hint I needed this evening to get &quot;Hello World!&quot; to run built with Eclipse. The Eclipse tutorials all stated to &quot;best practice&quot; put your Java source within a Package. They never explained how that would make things more complicated to run the resulting Java program.

In my case, I needed to have the current directory be just the bin directory... not where the .class file actually is.
Then execute command line: java com.g2.ExecJar.Start   Per your example.

Now I can get a good night&#039;s rest, and not have my mind thinking of things to try to get the Eclipse produced .class file to actually run with Java from the command line. Phew!!]]></description>
			<content:encoded><![CDATA[<p>Thank you for the hint I needed this evening to get &#8220;Hello World!&#8221; to run built with Eclipse. The Eclipse tutorials all stated to &#8220;best practice&#8221; put your Java source within a Package. They never explained how that would make things more complicated to run the resulting Java program.</p>
<p>In my case, I needed to have the current directory be just the bin directory&#8230; not where the .class file actually is.<br />
Then execute command line: java com.g2.ExecJar.Start   Per your example.</p>
<p>Now I can get a good night&#8217;s rest, and not have my mind thinking of things to try to get the Eclipse produced .class file to actually run with Java from the command line. Phew!!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Ngo Alalibo		</title>
		<link>https://www.jitendrazaa.com/blog/java/compile-and-run-java-program-in-package-from-command-line/#comment-5762</link>

		<dc:creator><![CDATA[Ngo Alalibo]]></dc:creator>
		<pubDate>Mon, 20 Jan 2020 18:51:13 +0000</pubDate>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=1984#comment-5762</guid>

					<description><![CDATA[thank you. Had been trying to do this for several hours until I read your post. You&#039;re right here &quot;...However there are users who frequently works on eclipse, netbeans or any other IDE and don’t know that how the program actually works behind the IDE.... &quot;]]></description>
			<content:encoded><![CDATA[<p>thank you. Had been trying to do this for several hours until I read your post. You&#8217;re right here &#8220;&#8230;However there are users who frequently works on eclipse, netbeans or any other IDE and don’t know that how the program actually works behind the IDE&#8230;. &#8220;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Lourthu		</title>
		<link>https://www.jitendrazaa.com/blog/java/compile-and-run-java-program-in-package-from-command-line/#comment-5684</link>

		<dc:creator><![CDATA[Lourthu]]></dc:creator>
		<pubDate>Tue, 17 Dec 2019 06:40:56 +0000</pubDate>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=1984#comment-5684</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.jitendrazaa.com/blog/java/compile-and-run-java-program-in-package-from-command-line/#comment-885&quot;&gt;Anonymous&lt;/a&gt;.

yes its working by the way you said..but what should i have to do the class files are in the same package where he classes are stored. bcz i&#039;m having two classes with in com.example.payroll. the first class employee.java has compiled successfully but when i try to compile Test.java which has initialization of an object employee class shows cannot find symbol error i don&#039;t know what is the reason here.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.jitendrazaa.com/blog/java/compile-and-run-java-program-in-package-from-command-line/#comment-885">Anonymous</a>.</p>
<p>yes its working by the way you said..but what should i have to do the class files are in the same package where he classes are stored. bcz i&#8217;m having two classes with in com.example.payroll. the first class employee.java has compiled successfully but when i try to compile Test.java which has initialization of an object employee class shows cannot find symbol error i don&#8217;t know what is the reason here.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: sahana		</title>
		<link>https://www.jitendrazaa.com/blog/java/compile-and-run-java-program-in-package-from-command-line/#comment-4310</link>

		<dc:creator><![CDATA[sahana]]></dc:creator>
		<pubDate>Sat, 14 Apr 2018 08:48:25 +0000</pubDate>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=1984#comment-4310</guid>

					<description><![CDATA[please give me solution sir]]></description>
			<content:encoded><![CDATA[<p>please give me solution sir</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: sahana		</title>
		<link>https://www.jitendrazaa.com/blog/java/compile-and-run-java-program-in-package-from-command-line/#comment-4309</link>

		<dc:creator><![CDATA[sahana]]></dc:creator>
		<pubDate>Sat, 14 Apr 2018 08:45:41 +0000</pubDate>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=1984#comment-4309</guid>

					<description><![CDATA[sir how to run this
import java.net.*;
import java.io.*;
import java.sql.*;
class trainserver
{
        public static void main(String args[])
        {
                String Query;
                ResultSet rs = null;
                String msg;
                int pnr = 0,trainnum=0;
                String from = new String();
                String to = new String();
                String date = new String();
                String name = new String();
                try
                {
                ServerSocket ser=new ServerSocket(8000);
                System.out.println(&quot;Server Started...&quot;);
                Socket soc=null;
                soc=ser.accept();
System.out.println(&quot;Received Connection:  &quot;+soc.getInetAddress().getHostAddress());
                DataOutputStream out=new DataOutputStream(soc.getOutputStream());
BufferedReader in  =  new BufferedReader(new InputStreamReader(soc.getInputStream()));
                try{
                Class.forName(&quot;sun.jdbc.odbc.JdbcOdbcDriver&quot;);
Connection conn=DriverManager.getConnection(&quot;jdbc:odbc:mydb&quot;,&quot;scott&quot;,&quot;tiger&quot;);
                Statement stmt=conn.createStatement();
                msg = in.readLine();
                pnr = Integer.parseInt(msg);
                Query = &quot;Select * from train where pnrno = &quot;+pnr;
                rs = stmt.executeQuery(Query);
                if(rs.next())
                {
                        pnr = Integer.parseInt(rs.getString(1));
                        from = rs.getString(2);
                        to = rs.getString(3);
                        date = rs.getString(4);
                        name = rs.getString(5);
                        trainnum=Integer.parseInt(rs.getString(6));
                }
                else
                {
                        System.out.println(&quot;invalid PNRNO&quot;);
                }
        }
                catch(SQLException e)
                {
                        System.out.println(&quot;Error Caught: &quot;+e); 
                }
                out.writeBytes(&quot;&quot;.valueOf(pnr));
                out.write(10);
                out.writeBytes(from);
                out.write(10);
                out.writeBytes(to);
                out.write(10);
                out.writeBytes(date);
                out.write(10);
                out.writeBytes(name);
                out.write(10);
                out.writeBytes(&quot;&quot;.valueOf(trainnum));
                out.write(10);
                soc.close();
                }
                catch(Exception e)
                {
                        System.out.println(&quot;Error Caught: &quot;+e);
                }
        }
}
//Client side

class traindbclient
{
        public static void main(String args[])
        {
                Socket objclient= null;
                BufferedReader br = null,in = null;
                DataOutputStream out = null;
                int pnr = 0;
                try
                {
                        objclient = new Socket(&quot;Localhost&quot;,8000);
in = new BufferedReader(new InputStreamReader(objclient.getInputStream()));
                        br = new BufferedReader(new InputStreamReader(System.in));
                        out = new DataOutputStream(objclient.getOutputStream());
                        System.out.println(&quot;Enter the PNR NO: &quot;);
                        pnr = Integer.parseInt(br.readLine());
                        out.flush();
                        out.writeBytes(&quot;&quot;.valueOf(pnr));
                        out.write(10);
                        System.out.println(&quot;PNRNo: &quot;+in.readLine());
                        System.out.println(&quot;SOURCE : &quot;+in.readLine());
                        System.out.println(&quot;DESTINATION: &quot;+in.readLine());
                        System.out.println(&quot;JOURNEY DATE: &quot;+in.readLine());
                        System.out.println(&quot;CUSTOMER NAME: &quot;+in.readLine());
                        System.out.println(&quot;TRAIN NO: &quot;+in.readLine());
                        objclient.close();
                }
                catch(Exception e)
                {
                        System.out.println(&quot;Error Caught: &quot;+e);
                }
        }
}]]></description>
			<content:encoded><![CDATA[<p>sir how to run this<br />
import java.net.*;<br />
import java.io.*;<br />
import java.sql.*;<br />
class trainserver<br />
{<br />
        public static void main(String args[])<br />
        {<br />
                String Query;<br />
                ResultSet rs = null;<br />
                String msg;<br />
                int pnr = 0,trainnum=0;<br />
                String from = new String();<br />
                String to = new String();<br />
                String date = new String();<br />
                String name = new String();<br />
                try<br />
                {<br />
                ServerSocket ser=new ServerSocket(8000);<br />
                System.out.println(&#8220;Server Started&#8230;&#8221;);<br />
                Socket soc=null;<br />
                soc=ser.accept();<br />
System.out.println(&#8220;Received Connection:  &#8220;+soc.getInetAddress().getHostAddress());<br />
                DataOutputStream out=new DataOutputStream(soc.getOutputStream());<br />
BufferedReader in  =  new BufferedReader(new InputStreamReader(soc.getInputStream()));<br />
                try{<br />
                Class.forName(&#8220;sun.jdbc.odbc.JdbcOdbcDriver&#8221;);<br />
Connection conn=DriverManager.getConnection(&#8220;jdbc:odbc:mydb&#8221;,&#8221;scott&#8221;,&#8221;tiger&#8221;);<br />
                Statement stmt=conn.createStatement();<br />
                msg = in.readLine();<br />
                pnr = Integer.parseInt(msg);<br />
                Query = &#8220;Select * from train where pnrno = &#8220;+pnr;<br />
                rs = stmt.executeQuery(Query);<br />
                if(rs.next())<br />
                {<br />
                        pnr = Integer.parseInt(rs.getString(1));<br />
                        from = rs.getString(2);<br />
                        to = rs.getString(3);<br />
                        date = rs.getString(4);<br />
                        name = rs.getString(5);<br />
                        trainnum=Integer.parseInt(rs.getString(6));<br />
                }<br />
                else<br />
                {<br />
                        System.out.println(&#8220;invalid PNRNO&#8221;);<br />
                }<br />
        }<br />
                catch(SQLException e)<br />
                {<br />
                        System.out.println(&#8220;Error Caught: &#8220;+e);<br />
                }<br />
                out.writeBytes(&#8220;&#8221;.valueOf(pnr));<br />
                out.write(10);<br />
                out.writeBytes(from);<br />
                out.write(10);<br />
                out.writeBytes(to);<br />
                out.write(10);<br />
                out.writeBytes(date);<br />
                out.write(10);<br />
                out.writeBytes(name);<br />
                out.write(10);<br />
                out.writeBytes(&#8220;&#8221;.valueOf(trainnum));<br />
                out.write(10);<br />
                soc.close();<br />
                }<br />
                catch(Exception e)<br />
                {<br />
                        System.out.println(&#8220;Error Caught: &#8220;+e);<br />
                }<br />
        }<br />
}<br />
//Client side</p>
<p>class traindbclient<br />
{<br />
        public static void main(String args[])<br />
        {<br />
                Socket objclient= null;<br />
                BufferedReader br = null,in = null;<br />
                DataOutputStream out = null;<br />
                int pnr = 0;<br />
                try<br />
                {<br />
                        objclient = new Socket(&#8220;Localhost&#8221;,8000);<br />
in = new BufferedReader(new InputStreamReader(objclient.getInputStream()));<br />
                        br = new BufferedReader(new InputStreamReader(System.in));<br />
                        out = new DataOutputStream(objclient.getOutputStream());<br />
                        System.out.println(&#8220;Enter the PNR NO: &#8220;);<br />
                        pnr = Integer.parseInt(br.readLine());<br />
                        out.flush();<br />
                        out.writeBytes(&#8220;&#8221;.valueOf(pnr));<br />
                        out.write(10);<br />
                        System.out.println(&#8220;PNRNo: &#8220;+in.readLine());<br />
                        System.out.println(&#8220;SOURCE : &#8220;+in.readLine());<br />
                        System.out.println(&#8220;DESTINATION: &#8220;+in.readLine());<br />
                        System.out.println(&#8220;JOURNEY DATE: &#8220;+in.readLine());<br />
                        System.out.println(&#8220;CUSTOMER NAME: &#8220;+in.readLine());<br />
                        System.out.println(&#8220;TRAIN NO: &#8220;+in.readLine());<br />
                        objclient.close();<br />
                }<br />
                catch(Exception e)<br />
                {<br />
                        System.out.println(&#8220;Error Caught: &#8220;+e);<br />
                }<br />
        }<br />
}</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Govindarajan D		</title>
		<link>https://www.jitendrazaa.com/blog/java/compile-and-run-java-program-in-package-from-command-line/#comment-2744</link>

		<dc:creator><![CDATA[Govindarajan D]]></dc:creator>
		<pubDate>Sun, 06 Sep 2015 19:06:00 +0000</pubDate>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=1984#comment-2744</guid>

					<description><![CDATA[Thanks :)]]></description>
			<content:encoded><![CDATA[<p>Thanks 🙂</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Aalsi Procrastinatior		</title>
		<link>https://www.jitendrazaa.com/blog/java/compile-and-run-java-program-in-package-from-command-line/#comment-2299</link>

		<dc:creator><![CDATA[Aalsi Procrastinatior]]></dc:creator>
		<pubDate>Wed, 08 Oct 2014 13:38:00 +0000</pubDate>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=1984#comment-2299</guid>

					<description><![CDATA[You are a life saver man! Thanks a ton :)]]></description>
			<content:encoded><![CDATA[<p>You are a life saver man! Thanks a ton 🙂</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: winnersravi meena		</title>
		<link>https://www.jitendrazaa.com/blog/java/compile-and-run-java-program-in-package-from-command-line/#comment-2263</link>

		<dc:creator><![CDATA[winnersravi meena]]></dc:creator>
		<pubDate>Wed, 03 Sep 2014 17:35:00 +0000</pubDate>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=1984#comment-2263</guid>

					<description><![CDATA[if i change the package name of Start.java then how to run it]]></description>
			<content:encoded><![CDATA[<p>if i change the package name of Start.java then how to run it</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: www.jitendrazaa.com @ 2026-06-24 03:54:33 by W3 Total Cache
-->