![]() |
|
SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here. |
![]() |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
Way to get a list of jars loaded into sage?
Header topic says it all it is late and I was just wondering short of calling a call and checking for an error.
|
#2
|
||||
|
||||
As I understand it, JARs as such aren't loaded at all. JARs are just containers for class definitions, like zip files. When instantiating a class for the first time, Java searches the available JARs and loads the definition it finds. If you want to know what JAR files will be searched, look in the JARs directory.
I believe there are reflection methods in the Java runtime to find out what classes have been loaded into memory so far, but that doesn't tell the whole story about what classes are available to be instantiated. What specific problem are you trying to solve?
__________________
-- Greg |
#3
|
|||
|
|||
Specifically jars either not being in the jars folder or sage being restarted to load the new jars. Specifically right now your jar for use with my imports just thought it would be nice to get a list of classes loaded so if yours or mine or something else was missing I could provide a simple propmt on the ui side of things. I could search the directory I guess for the jars I want but that wouldn't really tell me if they were loaded or not (ie sage restarted)
|
#4
|
||||
|
||||
Plucky, I'm still a little unsure what it is that you are trying to do... do I'll go over a couple of approaches... First, as Greg noted, jars are not really loaded, just searched. There are ways to tell which loaded class belongs to which jar (if that what you are after).
If want to test if a class is loadable, you can use Class.forName("youclass") and catch a class not found exception if the class does not exist. For example if you wanted to test if the phoenix jar was available you could use Class.forName("phoenix.api") and it will throw a ClassNotFound exception if it does not exist. But, if you are doing this all within java, to see if a user has your plugin installed correctly, then this code may never get triggered if it's inside one of your jars, that are not in the jars directory to begin with. In bmt, i do some checks when it starts, where it looks for duplicate jars (by scanning the jar folder), and I log duplicates. From the commandline, I actually remove duplicates (only my jars). Another approach is to check the versions of libraries that report a version. Phoenix contains an api phoenix.api.IsAtLeastVersion(Ver1, Ver2) that will return true if Ver1 is at least Ver2. ie, phoenix.api.IsAtLeastVersion(phoenix.api.GetVersion(), "1.44") Hope this helps.
__________________
Batch Metadata Tools (User Guides) - SageTV App (Android) - SageTV Plex Channel - My Other Android Apps - sagex-api wrappers - Google+ - Phoenix Renamer Downloads SageTV V9 | Android MiniClient |
#5
|
|||
|
|||
Thanks sean the class check will probably be the easiest approach. It just all comes down to people not extracting the zips correctly and getting the jars in the right location so rather than troubleshoot them and find out they have not got the jars in the right place I was just going to create a quick check at the start of the stv for the jars needed.
Thanks for the advice I sure wish there was a way to use new jars without a restart of sage service don't think it is possible but wanted to say ![]() |
#6
|
||||
|
||||
If you look at a debug log, about the second line from the top you'll see the classpath of JAR files that will be searched when trying to load a class. This classpath is built early during Sage startup by reading the contents of the JARs folder. Your problem is that a JAR dropped into that folder after Sage (or SageTVService) is already running won't be in that search path. That's what you're getting at when you talk about a JAR being "loaded" or not.
You can query the classpath yourself at runtime using java.lang.System.getProperty("java.class.path"). The result comes back as a giant semicolon-delimited string (like you see in the log file) that you can split into individual filenames or just search directly with String.contains(). That should tell you if a specific JAR was present in the JARs folder when Sage started.
__________________
-- Greg |
#7
|
||||
|
||||
Quote:
![]() Quote:
__________________
Batch Metadata Tools (User Guides) - SageTV App (Android) - SageTV Plex Channel - My Other Android Apps - sagex-api wrappers - Google+ - Phoenix Renamer Downloads SageTV V9 | Android MiniClient |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
When Sage is loaded, volume on computer is locked???? | though | SageTV Software | 2 | 03-17-2009 11:03 AM |
STVI loaded twice..help...please | garyellis | SageTV Software | 7 | 07-28-2006 04:53 PM |