Original article: Learning to compile and run C/C ++/java_linux programming _ Linux community-Linux System Portal website in Ubuntu
It turns out that no development kit was installed in Ubuntu, but it is more convenient to install GCC and G ++.
Sudo apt-Get install gcc
Apt-Get install make
Apt-Get install Autoconf
Apt-Get install automake
Apt-Get install libtool
Apt-Get install GDB
Apt-Get install g ++
Libtool seems to be needed. Otherwise, the compilation will fail to find the error message of stdio. h and other header files.
Then you can start pulling.
GCC hellopiggy. C-o hellopiggy. Out // compile
./Hellopiggy. Out // run
Of course, you can also use g ++
GCC hellopiggy. cpp-O hellopiggy. Out // compile
./Helloworld. Out // run
If a problem is found, the main function must be declared as int; otherwise, an error is returned: "Main must return int! "
-Now come to Java-
The Java environment has been installed before. I tried a lot in the afternoon and this was not a success. Both can be compiled successfully, but cannot run.
Exception in thread "Main" Java. Lang. noclassdeffounderror: hellopiggy/class
It seems that I haven't touched Java for too long. One problem is that I didn't set classpath and didn't add ". ", secondly, I am not familiar with the command line. I used Java hellopiggy. class (originally Java hellopiggy seems to have been too dependent on IDE)
If classpath is modified, sudo gedit/etc/environment
Add ":." at the end of the classpath line,
Or overwrite: classpath =$ {java_home}/lib/dt. Jar :$ {java_home}/lib/tools. jar :.
Finally, let's go here today.