LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-14-2022, 11:17 PM   #1
seamore
Member
 
Registered: Sep 2009
Posts: 83

Rep: Reputation: 1
Cant compile/run java program


I just download and expanded a jdk

tar xzvf jdk-8u311jdk-8u311-linux-x64.tar.gz

I went into the bin directory and tried to run the standard hellow world java program

When I ran javac* helloWorld.java I got the message “bash: .javac: cannot execute binary file”

All the files in the bin directory are -rwxr-xr-x

helloWorld.java:

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
 
Old 04-14-2022, 11:24 PM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,235

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
You need to set JAVA_HOME and PATH.

https://www.linuxquestions.org/quest...4/#post6017087
 
1 members found this post helpful.
Old 04-15-2022, 09:29 AM   #3
seamore
Member
 
Registered: Sep 2009
Posts: 83

Original Poster
Rep: Reputation: 1
I did.
 
Old 04-15-2022, 09:33 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,901

Rep: Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318
Quote:
Originally Posted by seamore View Post
I did.
Your posts contain no information, dropping in an error message is not enough to help you.
So please tell us exactly what did you execute, what's happened. Please post full output, not only a few lines.
http://catb.org/~esr/faqs/smart-ques...html#beprecise.

Or just look for pages on the net containing your error message (cannot execute binary file), like this:
https://superuser.com/questions/4359...te-binary-file
 
1 members found this post helpful.
Old 04-15-2022, 11:37 AM   #5
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,868
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
As a start:
Code:
set | egrep 'PATH|JAVA_HOME'
 
Old 04-15-2022, 12:23 PM   #6
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Originally Posted by seamore View Post
When I ran javac* helloWorld.java I got the message “bash: .javac: cannot execute binary file”
Did you literally put an asterisk after the javac? That looks wrong.
 
Old 04-16-2022, 07:54 PM   #7
seamore
Member
 
Registered: Sep 2009
Posts: 83

Original Poster
Rep: Reputation: 1
Thank all of you for the help.
I installed a jdk one version below and things worked.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
wan to Run c++ program in REHDAT as it run and compile in Turbo C++ AbidDhanaiser Linux - Software 1 09-21-2013 08:21 AM
How to compile and run a java program in linux? Aparna Raveendran Linux - Newbie 5 06-05-2012 11:23 AM
How to compile and run a java program in linux !!!! jmax24 Programming 7 08-06-2010 03:56 AM
cant compile java files in fedora 8.. java/ maranganesan Linux - Software 4 12-31-2007 12:21 PM
cant boot cant repair, cant reinstall... can i recover my files?? AnimaSola SUSE / openSUSE 4 08-07-2007 07:58 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration