Personal computing discussed

Moderators: renee, Dposcorp

 
ClickClick5
Gerbil Elite
Topic Author
Posts: 576
Joined: Fri Aug 15, 2008 8:28 pm
Location: Alaska
Contact:

Quick help with Java 9+

Wed Aug 29, 2018 8:46 pm

Hey all,

I have been working in Java since 1.4 and decided to try and bump up my programs to 1.9+. However, the removal of lib/ext is throwing me hard. Either I'm too tired to understand my problem, or something else is wrong.

I have my classpath set to where I now keep my .jar files for project imports (ie, Apache commons), and I'm able to compile the programs just fine. However when trying to run them, I get the grand "Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils" errors. In the past, placing the apache .jar in the jre /lib/ext fixed this. However it seems that the JRE is not pulling the jar from the classpath but the JDK is...

Any help would be greatly appreciated!
i7-5930k (4.1GHz), 32GB DDR4-2400, 980 4GB, GA-X99-UD3, Samsung 850 Pro 256GB (os/programs), Toshiba 5TB (games), WD VelociRaptor 500GB (games/scratch disk), Win 10 Pro x64
Check out my site for trance sets and other goodies! clickclick5.com!
 
DancinJack
Maximum Gerbil
Posts: 4494
Joined: Sat Nov 25, 2006 3:21 pm
Location: Kansas

Re: Quick help with Java 9+

Wed Aug 29, 2018 10:23 pm

Yeah, you got it right I think. You need to make sure all your dependencies are in the classpath at runtime. They get placed there for compile, but need to find them for runtime. Try placing io jar in your runtime classpath. (i left out version numbers and such as i have no idea what you're running, so I hope it makes sense the way I wrote it)
i7 6700K - Z170 - 16GiB DDR4 - GTX 1080 - 512GB SSD - 256GB SSD - 500GB SSD - 3TB HDD- 27" IPS G-sync - Win10 Pro x64 - Ubuntu/Mint x64 :: 2015 13" rMBP Sierra :: Canon EOS 80D/Sony RX100
 
ClickClick5
Gerbil Elite
Topic Author
Posts: 576
Joined: Fri Aug 15, 2008 8:28 pm
Location: Alaska
Contact:

Re: Quick help with Java 9+

Wed Aug 29, 2018 10:39 pm

So here is the layout:

CLASSPATH=J:\JavaProg\jars\*

The program is in J:\JavaProg\Programs\project\

I'm using the Apache Commons IO 2.6 called: commons-io-2.6.jar
This jar is currently in the classpath above.

So when compiling with either SciTool or in CMD, it compiles just fine. If finds the commons jar, compiles, all is well.
When I try to run the .class files either by SciTool or CMD, I get the java.lang.NoClassDefFoundError error.
I tried placing the commons file in with the compiled files in J:\JavaProg\Programs\project\ and I get the same error. Yet when I JAR them all together, it works fine. So for some reason, java 9 (and also tested 10.0.2) can see and compile fine, but the jre freaks out.

For java 1.4-1.8, I would place the jars in the jdk's lib/ext and jre's lib/ext and thing would run fine. I would compile, and all worked well. With ext being removed, I'm having problems finding how to get around this. All the documentation I keep finding says lib/ext is depreciated and to use classpath. Well....I am.........right?
i7-5930k (4.1GHz), 32GB DDR4-2400, 980 4GB, GA-X99-UD3, Samsung 850 Pro 256GB (os/programs), Toshiba 5TB (games), WD VelociRaptor 500GB (games/scratch disk), Win 10 Pro x64
Check out my site for trance sets and other goodies! clickclick5.com!
 
DancinJack
Maximum Gerbil
Posts: 4494
Joined: Sat Nov 25, 2006 3:21 pm
Location: Kansas

Re: Quick help with Java 9+

Wed Aug 29, 2018 10:47 pm

ClickClick5 wrote:
I tried placing the commons file in with the compiled files in J:\JavaProg\Programs\project\ and I get the same error. Yet when I JAR them all together, it works fine. So for some reason, java 9 (and also tested 10.0.2) can see and compile fine, but the jre freaks out.


what - the - heck is that crap. Ugh, Java. Sometimes makes me glad I'm more of a C++ person (only sometimes). However, I think I found something that will help you out?

http://www.oracle.com/technetwork/java/ ... DK-8049367
edit: another link that may be useful - http://openjdk.java.net/jeps/220
i7 6700K - Z170 - 16GiB DDR4 - GTX 1080 - 512GB SSD - 256GB SSD - 500GB SSD - 3TB HDD- 27" IPS G-sync - Win10 Pro x64 - Ubuntu/Mint x64 :: 2015 13" rMBP Sierra :: Canon EOS 80D/Sony RX100
 
ClickClick5
Gerbil Elite
Topic Author
Posts: 576
Joined: Fri Aug 15, 2008 8:28 pm
Location: Alaska
Contact:

Re: Quick help with Java 9+

Wed Aug 29, 2018 10:52 pm

DancinJack wrote:
ClickClick5 wrote:
I tried placing the commons file in with the compiled files in J:\JavaProg\Programs\project\ and I get the same error. Yet when I JAR them all together, it works fine. So for some reason, java 9 (and also tested 10.0.2) can see and compile fine, but the jre freaks out.


what - the - heck is that crap. Ugh, Java. Sometimes makes me glad I'm more of a C++ person (only sometimes). However, I think I found something that will help you out?

http://www.oracle.com/technetwork/java/ ... DK-8049367
edit: another link that may be useful - http://openjdk.java.net/jeps/220

" Applications that rely on this mechanism should consider deploying the libraries on the class path or as modules on the module path." BUT THEY ARE JAVA!!!
I feel like their decisions to do this was just to cause more issues. "Things working fine? Well we can't have that."
i7-5930k (4.1GHz), 32GB DDR4-2400, 980 4GB, GA-X99-UD3, Samsung 850 Pro 256GB (os/programs), Toshiba 5TB (games), WD VelociRaptor 500GB (games/scratch disk), Win 10 Pro x64
Check out my site for trance sets and other goodies! clickclick5.com!
 
DancinJack
Maximum Gerbil
Posts: 4494
Joined: Sat Nov 25, 2006 3:21 pm
Location: Kansas

Re: Quick help with Java 9+

Wed Aug 29, 2018 10:54 pm

hahahahha yes, indeed.

Btw, another worthwhile read: https://www.developer.com/java/java-9-s ... d-jre.html

"Effect of Modular JDK

Modular JDK provides the nifty freedom to combine JDK modules into a variety of configurations, according to the need. The idea is somewhat an augmentation of the concept of compact profiles introduced with Java 8. Custom configuration is particularly advantageous not only in creating scalable Java application but also shipping it in a runtime environment as a scalable platform. The configuration can have a specific set of modules as opposed to the Java platform as a monolithic artefact. This would leverage the performance, maintainability, and security of a Java application. The modular structure also introduced a new URI scheme for naming modules, classes, and resources stored in a runtime image. This strengthens the principle of encapsulation to a whole new level. Most of the JDK's internal APIs are hidden except a few critical ones, until some supported versions are introduced in future versions."
i7 6700K - Z170 - 16GiB DDR4 - GTX 1080 - 512GB SSD - 256GB SSD - 500GB SSD - 3TB HDD- 27" IPS G-sync - Win10 Pro x64 - Ubuntu/Mint x64 :: 2015 13" rMBP Sierra :: Canon EOS 80D/Sony RX100
 
ClickClick5
Gerbil Elite
Topic Author
Posts: 576
Joined: Fri Aug 15, 2008 8:28 pm
Location: Alaska
Contact:

Re: Quick help with Java 9+

Thu Aug 30, 2018 5:20 pm

I was able to work around the issue by extracting the jar in the classpath. Now everything is happy. Not sure why it can not read the jar at runtime anymore, but whatever. It works after it has been jar-ed, but now I can compile/test without having to jar the project each time.
i7-5930k (4.1GHz), 32GB DDR4-2400, 980 4GB, GA-X99-UD3, Samsung 850 Pro 256GB (os/programs), Toshiba 5TB (games), WD VelociRaptor 500GB (games/scratch disk), Win 10 Pro x64
Check out my site for trance sets and other goodies! clickclick5.com!
 
bthylafh
Maximum Gerbil
Posts: 4316
Joined: Mon Dec 29, 2003 11:55 pm
Location: Southwest Missouri, USA

Re: Quick help with Java 9+

Thu Aug 30, 2018 6:22 pm

Apropos of nothing, there's a rancher around here somewhere who will sometimes move cattle in a foul, malodorous livestock trailer, the latter emblazoned with "JDK". It gives me a grin every time I see it.
Hakkaa päälle!
i7-8700K|Asus Z-370 Pro|32GB DDR4|Asus Radeon RX-580|Samsung 960 EVO 1TB|1988 Model M||Logitech MX 518 & F310|Samsung C24FG70|Dell 2209WA|ATH-M50x
 
just brew it!
Administrator
Posts: 53995
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Quick help with Java 9+

Thu Aug 30, 2018 6:36 pm

Believe it or not, I've managed to get through a 3+ decade career in software development without dealing with Java, other than learning just enough of it to help my son with his AP CS homework when he was in high school a number of years back. Due to circumstances not entirely under my control that may be about to change, but I'd just as soon not bother with it. (The business unit I currently work for is a mostly-Java shop, but all the stuff I've dealt with here so far has been C++, Python, or bash shell.)
Nostalgia isn't what it used to be.
 
DancinJack
Maximum Gerbil
Posts: 4494
Joined: Sat Nov 25, 2006 3:21 pm
Location: Kansas

Re: Quick help with Java 9+

Thu Aug 30, 2018 7:54 pm

just brew it! wrote:
Believe it or not, I've managed to get through a 3+ decade career in software development without dealing with Java, other than learning just enough of it to help my son with his AP CS homework when he was in high school a number of years back. Due to circumstances not entirely under my control that may be about to change, but I'd just as soon not bother with it. (The business unit I currently work for is a mostly-Java shop, but all the stuff I've dealt with here so far has been C++, Python, or bash shell.)

Luuuuuuuuucky.

My first year of CS was C++ (two semesters) and then a year of Java (long live Eclipse - we were doing C++ in Emacs and the command line for EVERYTHING). After that it was kinda your choice (I didn't go further in CS, but knew the required and elective classes). I've gotten into Java a bit more for native Android dev stuff (and more recently Kotlin), and I just never have to deal with the JDK/JRE on a regular basis anymore thank goodness.
i7 6700K - Z170 - 16GiB DDR4 - GTX 1080 - 512GB SSD - 256GB SSD - 500GB SSD - 3TB HDD- 27" IPS G-sync - Win10 Pro x64 - Ubuntu/Mint x64 :: 2015 13" rMBP Sierra :: Canon EOS 80D/Sony RX100
 
just brew it!
Administrator
Posts: 53995
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Quick help with Java 9+

Thu Aug 30, 2018 8:13 pm

Yeah, so far I'm perfectly happy being one of the token devs there who is more comfortable with C/C++ and Python. Kinda keeps me out of the center of the storm, I think.
Nostalgia isn't what it used to be.
 
Veerappan
Gerbil
Posts: 35
Joined: Mon Jun 23, 2008 5:06 pm

Re: Quick help with Java 9+

Thu Aug 30, 2018 9:54 pm

just brew it! wrote:
Yeah, so far I'm perfectly happy being one of the token devs there who is more comfortable with C/C++ and Python. Kinda keeps me out of the center of the storm, I think.


Meh, it pays the bills.... although I have a lot more fun after-hours doing C dev on things like the mesa project.

On Topic: You might be able to get around the issue by also just building your project as a jar-with-dependencies (a.k.a. uberjar).

https://maven.apache.org/plugins/maven- ... usage.html

I'm assuming maven, but I'm sure there's equivalent options in other build systems... and if for some reason you're still stuck on ANT.... I'm sorry.
 
ClickClick5
Gerbil Elite
Topic Author
Posts: 576
Joined: Fri Aug 15, 2008 8:28 pm
Location: Alaska
Contact:

Re: Quick help with Java 9+

Fri Sep 07, 2018 10:53 pm

What gets me with Java is the constant changing of the guard. Looonnnngggg release times, then each release would add new things and break some old dependencies, ect. But were easy to fix (most of the time). Then Oracle buys java. Still long release times and many new features, but more broken stuff. Ok ok, so, more to fix, and now back together again. People complain about the long release schedule, so Oracle is now pumping a new version every 6 months (like many linux distros) with alternating years being the LTS version. So if you use the non LTS versions, Oracle supports them for a tiny amount of time before having OpenJDK manage it. In with all this, things get broke. I mean, you can code as cleanly as possible, requiring the least amount of trickery to get things to work, but when some ass-hat decides to change or remove a common feature for some screwy reason, then there is a lot to go back and edit.

I'm still waiting for the time where "public static void main" will be depreciated. :evil:
i7-5930k (4.1GHz), 32GB DDR4-2400, 980 4GB, GA-X99-UD3, Samsung 850 Pro 256GB (os/programs), Toshiba 5TB (games), WD VelociRaptor 500GB (games/scratch disk), Win 10 Pro x64
Check out my site for trance sets and other goodies! clickclick5.com!
 
Waco
Grand Gerbil Poohbah
Posts: 3346
Joined: Tue Jan 20, 2009 4:14 pm
Location: Los Alamos, NM

Re: Quick help with Java 9+

Fri Sep 07, 2018 11:20 pm

I wish I could help, but I avoid Java like the plague. C, C++, and Fortran for the win!
Desktop: X570 Gaming X | 3900X | 32 GB | Alphacool Eisblock Radeon VII | Heatkiller R3 | Samsung 4K 40" | 1 TB SX8200 Pro + 2 TB 660p + 2 TB SATA SSD
NAS: 1950X | Designare EX | 32 GB ECC | 7x8 TB RAIDZ2 | 8x2 TB RAID10 | FreeNAS | ZFS | LSI SAS
 
just brew it!
Administrator
Posts: 53995
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Quick help with Java 9+

Sat Sep 08, 2018 7:35 am

Waco wrote:
I wish I could help, but I avoid Java like the plague. C, C++, and Fortran for the win!

I really loved Python until I got stuck maintaining someone else's badly written Python project, and discovered the many creative ways in which the language can be abused to create completely incomprehensible code with non-deterministic behaviors. :wink:

To be fair, modern dialects of C++ are just as bad in this regard, and the error messages are less helpful when things go badly wrong... but as a group, C++ developers seem to have somewhat more of a clue since it tends to scare the n00bs away. :lol:
Nostalgia isn't what it used to be.
 
Topinio
Gerbil Jedi
Posts: 1784
Joined: Mon Jan 12, 2015 9:28 am
Location: London

Re: Quick help with Java 9+

Sun Sep 09, 2018 3:36 pm

Waco wrote:
C, C++, and Fortran for the win!

Certainly the latter; C seems reasonable enough, not sure about that Python stuff, 'tis a silly place.
Desktop: E3-1270 v5, X11SAT-F, 32GB, RX 580, 500GB P1, 250GB MX500, 4TB 7E8, Xonar DGX, XL2730Z + L22e-20
HTPC: i5-2500K, DH67GD, 4GB, GT 1030, 250GB MX500, 1.5TB ST1500DL003, KDL32EX503U + KA220HQ
Laptop: MacBookPro15,2

Who is online

Users browsing this forum: No registered users and 3 guests
GZIP: On