Java

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

Java

#1 Post by jpeps »

I've been experimenting with java as a cross-platform language, and wrote a library database that works nicely on linux and windows with the latest Java JRE binaries (an easy download from Oracle does it). Run the files with "java -jar file.jar" I had to switch to OpenBox WM, since there's a conflict with JWM and java files.

Here's a library app to test. <Add> or <Remove> handles books on a clickable alphabetized list. Clicking an item writes the title and author into the entry boxes, and posts the original entry date. There's a button for getting the total number of books.

Data from the book class is written in XML format into the mlData folder, along with the book-list.

http://jpeters.net/apps/MyLibrary3.jar

Updated: Cut File size by a third; added publish info.
Updated: Streamlined code.

Updated: 4/4/13
All data now in one MyLibrary.xml file
Add author and title search buttons (repeated click gets next selection)
Attachments
MyLibrary3.png
(15.71 KiB) Downloaded 1892 times
Last edited by jpeps on Fri 05 Apr 2013, 07:52, edited 2 times in total.

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#2 Post by jpeps »

Working jre: (updated)

http://www.jpeters.net/apps/jre1-7.0.13-001.sfs.tar.gz

ffde09235525e75dd8468741cc361123
Last edited by jpeps on Fri 08 Feb 2013, 08:35, edited 3 times in total.

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#3 Post by jpeps »

I was able to knock 63% off use of RAM with -Xmxn option (n=size). 2m is minimum.

example: in ROX, set run action to:
java -Xmx2m -jar "$@"

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#4 Post by jpeps »

Here's a text editor I built that sorts alphanumerically or by line size to a "sort.txt" file. This one's only 8K. Create and save a new list from within the editor, or just copy over the file.

Updated: includes open, save as dialogs. Closing with exit button records last file, which opens on next session.
Updated: includes a line number sort.
Attachments
SortEditor.png
(10.08 KiB) Downloaded 1715 times
SortEditor.tar.gz
(12.25 KiB) Downloaded 960 times
Last edited by jpeps on Fri 18 Jan 2013, 06:27, edited 2 times in total.

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#5 Post by jpeps »

Updated the sort editor with open file and save as dialogues. It's still about 12K, and runs fast even on my old dell. Also, it runs on everything I tested it on. I'm definitely rethinking the whole java thing.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#6 Post by sunburnt »

Yep, that`s what drew me to it many years ago.
And it ( like C ) does very well in the portability department.

I was dismayed by the long learning curve, but it`s much like C.
It needs a really good class browser that has many search methods.

The other thing is... Does it compile to binary ( can`t remember ).

### The thought that I had...
Android is nearly a tablet + desktop O.S. ( amigo called it an interface ).
I`m thinking that making it desktop capable would kill Linux and Weeners.

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#7 Post by jpeps »

sunburnt wrote:
I was dismayed by the long learning curve, but it`s much like C.
It needs a really good class browser that has many search methods.
There are great tools like Eclipse that make it quite easy. Eclipse will offer suggestions and insert code for you as you program. There's also a ton of help on the internet.

The other thing is... Does it compile to binary ( can`t remember ).
Yes...it writes "bytecode" to the Java Virtual Machine
### The thought that I had...
Android is nearly a tablet + desktop O.S. ( amigo called it an interface ).
I`m thinking that making it desktop capable would kill Linux and Weeners.
Interface, as in extension vs replacement sounds correct. The JVM still doesn't exploit the individual computer's hardware (graphic card, etc) very efficiently. There's currently lots of development going on, so things should only improve. For programmers, it's a tool you can really sink your teeth into.

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#8 Post by 01micko »

jpeps,

What's the conflict with jwm? Joe is currently working on jwm and has written some java stuff too, so he should be able to fix it.
Puppy Linux Blog - contact me for access

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#9 Post by jpeps »

01micko wrote:jpeps,

What's the conflict with jwm? Joe is currently working on jwm and has written some java stuff too, so he should be able to fix it.
Text entry loses focus, and you can't get it back.

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#10 Post by 01micko »

jpeps,

Do you mind trying the latest version and see if it continues? You'll have to compile it. http://joewing.net/projects/jwm/snapsho ... 52.tar.bz2 , direct link to source
Puppy Linux Blog - contact me for access

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#11 Post by jpeps »

01micko wrote:jpeps,

Do you mind trying the latest version and see if it continues? You'll have to compile it. http://joewing.net/projects/jwm/snapsho ... 52.tar.bz2 , direct link to source
Same issue with ver -652

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#12 Post by 01micko »

Ok, I see it too, Even Joe's program (ShareBrowse.jar) doesn't work. I'm sure his geek pride will want that fixed.
Puppy Linux Blog - contact me for access

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#13 Post by jpeps »

01micko wrote:Ok, I see it too, Even Joe's program (ShareBrowse.jar) doesn't work. I'm sure his geek pride will want that fixed.
:)

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#14 Post by 01micko »

jpeps wrote:
01micko wrote:Ok, I see it too, Even Joe's program (ShareBrowse.jar) doesn't work. I'm sure his geek pride will want that fixed.
:)
Reported. :wink:
Puppy Linux Blog - contact me for access

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#15 Post by 01micko »

Fixed in JWM-653 :) .. now I can try your programs :)
Puppy Linux Blog - contact me for access

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#16 Post by jpeps »

01micko wrote:Fixed in JWM-653 :) .. now I can try your programs :)
damn....you're my hero :)

works!

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#17 Post by jpeps »

Updated the sort editor with a line number sort; parses out and sorts numbers at the beginning of a line, eliminates blank lines, sorts non-numeric lines after the number lines, etc. The alphanumeric sort orders numbers 1-9 and then places 10 after 1.

Interesting thing about java, is that you build the function in a separate, reusable class which can then be used by other projects.

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#18 Post by jpeps »

Updated working jre to latest security patch (on first page)

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#19 Post by 01micko »

jpeps wrote:Updated working jre to latest security patch (on first page)
Thanks for that. By chance do you have a build script for java? Kind of a tarball to sfs thing?
Puppy Linux Blog - contact me for access

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#20 Post by jpeps »

01micko wrote:
jpeps wrote:Updated working jre to latest security patch (on first page)
Thanks for that. By chance do you have a build script for java? Kind of a tarball to sfs thing?
It was a little tricky getting the link to work.

Code: Select all

#!/bin/sh

jre="jre1.7.0_17"
temp="jre1.7.0_17_001"

mkdir -p "/tmp/${temp}/usr/local/bin"
mkdir -p "/usr/local/${jre}/bin"

##  GET PACKAGE
wget -O "/tmp/${jre}.tar.gz"  http://javadl.sun.com/webapps/download/AutoDL?BundleId=75250


## UNPACK AND MOVE TO NEW FOLDER
cd /tmp
tar -xvzf "/tmp/${jre}.tar.gz"
 mv  "${jre}"    "${temp}/usr/local"

 
## COPY JAVA FILES FOR LINKING

cd "${temp}/usr/local"
cp   "${jre}/bin/java"  "/usr/local/${jre}/bin"     

cd "/tmp/${temp}/usr/local/bin"
ln -s "/usr/local/${jre}/bin/java" . 


## CHANGE NAME FOR SFS BUILD
cd /tmp
mv "${temp}" "${jre}"

dir2sfs "$jre"

## Change name and CLEAN UP
 
name="$(ls | grep jre1*sfs | grep -v "txt")"

mv "$name"  jre1-7.0-17.sfs

rm -r "/usr/local/${jre}"
rm -r "/tmp/${jre}"
rm  "/tmp/${jre}.tar.gz"
rm /tmp/jre1*txt

echo  "jre1-7.0-17.sfs is in /tmp"







Last edited by jpeps on Sat 30 Mar 2013, 02:00, edited 5 times in total.

Post Reply