LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-10-2017, 03:49 AM   #1
p\_/ppy
LQ Newbie
 
Registered: May 2016
Posts: 14

Rep: Reputation: Disabled
how to run .java file with Geany in puppy linux


In Geany, wrote following code,
Code:
public class HlloWd {

	public static void main(String[] args) {		
		System.out.println("Hello World"); 
	}

}
Document> Set Filetype> Programming Languages> Java Source Code (ticked)
Build> Set Build Commands> Compile> "/mnt/home/PPP/Download/Installer/jdk1.8.0_111/bin/javac" "%d\%f" (filled)
Execute> "/mnt/home/PPP/Download/Installer/jdk1.8.0_111/bin/java" "-classpath" "%d" "%e" (filled)
>OK
click Compile> got err msg:
[err_msg]
“/mnt/home/PPP/Download/Installer/jdk1.8.0_111/bin/javac” “mnt/home/PPP/java\HlloWd.java” (in directory. /mnt/home/PPP/java)
javac: file not found: /mnt/home/PPP/java\HlloWd.java
Usage: javac <options> <source files>
use -help for a lost of possible options
compilation failed.
[/err_msg]
> Help me and thank you all!
 
Old 01-12-2017, 05:59 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,272

Rep: Reputation: 7694Reputation: 7694Reputation: 7694Reputation: 7694Reputation: 7694Reputation: 7694Reputation: 7694Reputation: 7694Reputation: 7694Reputation: 7694Reputation: 7694
there is a \ in the filename (set build command), probably you need to use / instead
 
Old 02-05-2017, 05:38 AM   #3
p\_/ppy
LQ Newbie
 
Registered: May 2016
Posts: 14

Original Poster
Rep: Reputation: Disabled
I've tried it, but no help. maybe, i need to config according to manual which i've not read yet.
 
Old 02-05-2017, 06:07 AM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by p\_/ppy View Post
I've tried it, but no help.
tried what?
please show us, complete code etc.
please use code tags for code.
 
Old 02-13-2017, 11:53 AM   #5
p\_/ppy
LQ Newbie
 
Registered: May 2016
Posts: 14

Original Poster
Rep: Reputation: Disabled
Well, i tried it
// at first
Build> Set Build Commands> Compile> "/mnt/home/PPP/Download/Installer/jdk1.8.0_111/bin/javac" "%d\%f" (filled)
//tried changing
Build> Set Build Commands> Compile> "/mnt/home/PPP/Download/Installer/jdk1.8.0_111/bin/javac" "%d/%f" (filled) //"%d/%f" is what i changed

when i tried long ago, i got compilation failed err.
but now i tried n compilation finished successfully. (dunno what the differences)

well, got another problem.
for C++, click Compile (after finished successfully), Build then, Execute
Then in terminal, cd /mnt/home/my/directory
and next line, ./helloWorld.cpp
and there comes the output

but for java, Compile, Build, Execute, got helloWorld.class file
in terminal, the same as for C++,
got "cannot execute binary file"
then how do i see my output?
 
Old 02-13-2017, 11:57 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,272

Rep: Reputation: 7694Reputation: 7694Reputation: 7694Reputation: 7694Reputation: 7694Reputation: 7694Reputation: 7694Reputation: 7694Reputation: 7694Reputation: 7694Reputation: 7694
would be nice to see exactly what have you tried.
 
Old 02-14-2017, 01:54 AM   #7
Jjanel
Member
 
Registered: Jun 2016
Distribution: any&all, in VBox; Ol'UnixCLI; NO GUI resources
Posts: 999
Blog Entries: 12

Rep: Reputation: 364Reputation: 364Reputation: 364Reputation: 364
[I'm guessing] You need to 'have' java run it (not the shell).
http://stackoverflow.com/questions/1...ckage-from-cmd
Not the best link, but I'm not 'into' java/GUI,
so I welcome another LQ'er to explain this better!

**Also, read/study: http://wikipedia.org/wiki/Shebang_(Unix)
Code:
# head -1 MyWorld.class
▒▒▒▒3G
Note that: this/any? .class file is binary, not text, so no #!... first line!

The Unix `file` command/concept comes to mind; here's some .... [junk]
(again, I don't have java installed in this CLI-only VBox VirtualMachine)

[CODE]
root@trisquel:~# find / -xdev -name \*.class | head -1
/usr/share/nmap/nselib/data/jdwp-class/JDWPExecCmd.class
root@trisquel:~# cp /usr/share/nmap/nselib/data/jdwp-class/JDWPExecCmd.class MyWorld.class
root@trisquel:~#
root@trisquel:~# chmod 755 MyWorld.class #<<<NOT needed/appropriate; just to demo error here!
root@trisquel:~# ./MyWorld.class
bash: ./MyWorld.class: cannot execute binary file: Exec format error
root@trisquel:~#
root@trisquel:~# file MyWorld.class
MyWorld.class: compiled Java class data, version 51.0
root@trisquel:~# file /bin/ls
/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=cecbb9e27978d91bc6fe2cc4d46d0cd58deafdb2, stripped
root@trisquel:~# file `which update-grub`
/usr/sbin/update-grub: POSIX shell script, ASCII text executable
root@trisquel:~#
[/CODE]

p.s. does Linux 'know' how to run a .cpp file?
Code:
./helloWorld.cpp
Yes? Cool! No? I wonder what **exactly** OP p\_/ppy did...

p.p.s. PLEASE use: CODE ...YourStuff... /CODE 'tags' (note the square-brackets!)
Looks a **lot** nicer, yes? (you can use the 'Edit' button, to fix your posts)
Code:
root@trisquel:~# find / -xdev -name \*.class | head -1 
/usr/share/nmap/nselib/data/jdwp-class/JDWPExecCmd.class 
root@trisquel:~# cp /usr/share/nmap/nselib/data/jdwp-class/JDWPExecCmd.class MyWorld.class 
root@trisquel:~# 
root@trisquel:~# chmod 755 MyWorld.class #<<<NOT needed/appropriate; just to demo error here!
root@trisquel:~# ./MyWorld.class 
bash: ./MyWorld.class: cannot execute binary file: Exec format error 
root@trisquel:~# 
root@trisquel:~# file MyWorld.class 
MyWorld.class: compiled Java class data, version 51.0 
root@trisquel:~# file /bin/ls  
/bin/ls: ELF 32-bit LSB  executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=cecbb9e27978d91bc6fe2cc4d46d0cd58deafdb2, stripped 
root@trisquel:~# file `which update-grub` 
/usr/sbin/update-grub: POSIX shell script, ASCII text executable 
root@trisquel:~#
p.p.p.s.: My web-research of the day: .pdf c++ java linux run*
Whoa! 955,000links, 500pages each! ...Back in a few years
Or, in a few days: http://horstmann.com/ccc/c_to_java.pdf or this

Last edited by Jjanel; 02-14-2017 at 05:32 PM.
 
1 members found this post helpful.
Old 02-15-2017, 11:30 PM   #8
p\_/ppy
LQ Newbie
 
Registered: May 2016
Posts: 14

Original Poster
Rep: Reputation: Disabled
Ah.. Thanks a lot. Jjanel.

your above link helped me.
Code:
package jj;

public class HlloWd {

	public static void main(String[] args) {		
		System.out.println("Hello World"); 
	}

}
save as HlloWd.java in the directory "/mnt/home/PPP/jj"
well, can't save in java directory or folder.
coz...
Quote:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.SecurityException: Prohibited package name: java
will occur
then compile, build, execute
then in terminal,
Code:
cd /mnt/home/PPP
note that we don't go till jj directory
Code:
java jj.HlloWd
got cha
Code:
Hello World
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] Geany how to fold a text file S. Chapelin Linux - Software 8 08-13-2020 09:39 AM
setcap (file capabilties ) at run time for java in Linux gaurav_s Linux - Software 0 08-07-2015 08:45 AM
how to run .class java file? rabbit2345 Programming 2 01-24-2008 11:43 AM
How to run a java jar file. sabliny Programming 7 11-05-2005 02:59 PM
Java, I have downloaded the .bin file and run it ... now what ? TroelsSmit Linux - Newbie 3 03-02-2004 11:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:41 PM.

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