user46931: I am building a clock with an Arduino.
Most clocks have a RTC module or some kind of RTC chip in order to get the time. I do not.
How do i replace this chip with software? Is there a C/C++ library equivalent to the Java library  java.util.date? 
Can I run a Java program instead of a C program on my Arduino so I can use this Java library? I only know Java and have little experience with C/C++. I have looked into ways to program this clock in Java which I have had success with, but this is only in my computer, not in the Arduino.

user10394: Having looked at you other question it seems you are trying to run before you can walk.  You may be a good java programmer, but you need to get your head around C++ before you go all in and build a clock.
To answer this question, yes there are ways to get software to keep time, but when you power it up, how do you know what the time is?  This is where having a RTC will help, there are plenty of bare ICs out there and even ones with libraries.  
If you had a network then you could grab the header data from the network packets, but you are running this on a Mega, which seems an odd choice for something as simple as a network time clock, surly a nano would do, or an ESP8266.  
These links will help you, but personally I think you need to break the problem down into smaller chunks.
https://www.arduino.cc/reference/en/
https://playground.arduino.cc/Code/Time

user7508: 
how do i replace [an RTC] chip with software?

You can't. An RTC is made of basically two things:

a carefully trimmed crystal oscillator that has a very stable and well
calibrated frequency
some logic to count the oscillations and convert that to time and
date.

The logic can be easily replaced by software, but the crystal cannot.
Any “pure software” solution you may find ultimately relies on counting
cycles of the system clock (the signal that clocks the whole
microcontroller). On most Arduinos, including the Uno, the system clock
is based on a ceramic resonator. These are usually specified with
0.5% frequency tolerance, and they typically have a frequency offset of
about ±0.1%. That's a drift of ±44 minutes per month!
You can get better accuracy by calibrating your Arduino's clock, and
correcting by software the frequency offset you measure. However, the
frequency is not only off, it is also quite unstable, and very sensitive
to temperature variations. So even with calibration you end up with a
clock that is ridiculously bad compared with the cheapest quartz watch.

is there a c++ library equivalent to the java library java.util.date?

I don't know Java, but there are C++ libraries available for managing
time. For example, you could initialize Paul Stoffregen's TimeLib as
follows:
setTime(hr,min,sec,day,mnth,yr);  // set initial time
setSyncInterval(-1);  // pretend we don't need to resync

and then periodically query the time with now(). That should be all
you need to build a “proof of concept” of your clock: it will tell you
the time, but with an awfully bad long-term accuracy.
Note that, once you add an RTC or another good time source, you can add
a “time provider” to that library, keep the rest of your code unchanged,
and benefit from the accuracy of your new time source.

Can i run a java program instead of a c program on my arduino [...]?

No, you can't. A Java runtime will never fit in your Arduino.

46931: <p>I am building a clock with an Arduino.</p>

<p>Most clocks have a RTC module or some kind of RTC chip in order to get the time. I do not.</p>

<p>How do i replace this chip with software? Is there a C/C++ library equivalent to the Java library  <code>java.util.date</code>? </p>

<p>Can I run a Java program instead of a C program on my Arduino so I can use this Java library? I only know Java and have little experience with C/C++. I have looked into ways to program this clock in Java which I have had success with, but this is only in my computer, not in the Arduino.</p>
 10394: <p>Having looked at you other question it seems you are trying to run before you can walk.  You may be a good java programmer, but you need to get your head around C++ before you go all in and build a clock.</p>

<p>To answer this question, yes there are ways to get software to keep time, but when you power it up, how do you know what the time is?  This is where having a RTC will help, there are plenty of bare ICs out there and even ones with libraries.  </p>

<p>If you had a network then you could grab the header data from the network packets, but you are running this on a Mega, which seems an odd choice for something as simple as a network time clock, surly a nano would do, or an ESP8266.  </p>

<p>These links will help you, but personally I think you need to break the problem down into smaller chunks.</p>

<p><a href="https://www.arduino.cc/reference/en/" rel="nofollow noreferrer">https://www.arduino.cc/reference/en/</a></p>

<p><a href="https://playground.arduino.cc/Code/Time" rel="nofollow noreferrer">https://playground.arduino.cc/Code/Time</a></p>
 7508: <blockquote>
<p>how do i replace [an RTC] chip with software?</p>
</blockquote>
<p>You can't. An RTC is made of basically two things:</p>
<ul>
<li>a carefully trimmed crystal oscillator that has a very stable and well
calibrated frequency</li>
<li>some logic to count the oscillations and convert that to time and
date.</li>
</ul>
<p>The logic can be easily replaced by software, but the crystal cannot.
Any “pure software” solution you may find ultimately relies on counting
cycles of the system clock (the signal that clocks the whole
microcontroller). On most Arduinos, including the Uno, the system clock
is based on a <a href="https://en.wikipedia.org/wiki/Ceramic_resonator" rel="nofollow noreferrer">ceramic resonator</a>. These are usually specified with
0.5% frequency tolerance, and they typically have a frequency offset of
about ±0.1%. That's a drift of ±44 minutes per month!</p>
<p>You can get better accuracy by calibrating your Arduino's clock, and
correcting by software the frequency offset you measure. However, the
frequency is not only off, it is also quite unstable, and very sensitive
to temperature variations. So even with calibration you end up with a
clock that is ridiculously bad compared with the cheapest quartz watch.</p>
<blockquote>
<p>is there a c++ library equivalent to the java library java.util.date?</p>
</blockquote>
<p>I don't know Java, but there are C++ libraries available for managing
time. For example, you could initialize Paul Stoffregen's <a href="https://github.com/PaulStoffregen/Time" rel="nofollow noreferrer">TimeLib</a> as
follows:</p>
<pre><code>setTime(hr,min,sec,day,mnth,yr);  // set initial time
setSyncInterval(-1);  // pretend we don't need to resync
</code></pre>
<p>and then periodically query the time with <code>now()</code>. That should be all
you need to build a “proof of concept” of your clock: it will tell you
the time, but with an awfully bad long-term accuracy.</p>
<p>Note that, once you add an RTC or another good time source, you can add
a “time provider” to that library, keep the rest of your code unchanged,
and benefit from the accuracy of your new time source.</p>
<blockquote>
<p>Can i run a java program instead of a c program on my arduino [...]?</p>
</blockquote>
<p>No, you can't. A Java runtime will never fit in your Arduino.</p>
