Compile and run C/C ++/Java in Ubuntu

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.