Importing a downloaded JAR file into a Servlet - json

I have recently downloaded the json-lib jar, and added it to my libraries using NetBean's library wizard.
I believe to import net.sf.json.JSONObject, I first have to call the package at the beginning of the servlet file.
However, when I try to do 'package net.sf.json', I get the error 'class, interface or enum expected'.
I have placed the jar in the WEB-INF/lib folder. I am certain I'm missing something, but I'm not certain what. Any advice would be appreciated.

Related

Contentfile in nuget gets compiled causing build errors

I have a nuget that has a contentfile in it. It is a json file and denoted in the nuspec file when the nuget is packed.
When installing the nuget in a regular wpf app, I get a couple build errors. It appears that Visual Studio is trying to compile the .json file. Wondering if anyone knows what may cause this. As you'll see in the nuspec snippet I have BuildAction=None in the nuspec
ContentFile.json(1,1,1,2): error CS1022: Type or namespace definition, or end-of-file expected
ContentFile.json(4,16,4,26): error CS1001: Identifier expected
ContentFile.json(4,37,4,45): error CS1001: Identifier expected
When installing the nuget in a regular wpf app, I get a couple build
errors. It appears that Visual Studio is trying to compile the .json
file. Wondering if anyone knows what may cause this. As you'll see in
the nuspec snippet I have BuildAction=None in the nuspec
I think the main point is that you mistakenly assume that <files include="path"> is the path of the source file ContentFile.json in your current nuget project, which is actually the path relative to the contentFiles folder inside the nuget package(xxxx.nupkg).(You can view the contentFiles folder by decompressing the xxx.nupkg file).
Besides, you can check this official document for more detailed info.
As a right guidance, you can try this step:
Solution
change to these in xxx.nuspec file
....
<metadata>
....
<contentFiles>
<files include="any/any/ContentFile.json"(the relativepath of the file under the ContentFiles folder in the xxx.nupkg) buildAction="None" copyToOutput="true" flatten="false" />
</contentFiles>
</metadata>
<files>
<file src="xxxxx/Resource/ContentFile.json(the relativePath of the file under the nuget project)" target="contentFiles/any/any" />
</files>
....
Before you install this package into another project , do not forget to clean the nuget cache.
In additon, you can check this thread for more info.
Hope it could help you.

Warning: Could not find file C:\Users\Harsh Jain\Downloads\com.mysql.jdbc_5.1.5.jar\co

I am getting this error while running the Student Management System project in netbeans Ide project in made in java,jsp,html.Please help me
Your project's build has a dependency on the Java ARchive (.jar file) com.mysql.jdbc_5.1.5
There are two possibilities that I see here, without further details on what you have done so far:
1) You already downloaded the jar, but when you specified the path where your build process is gonna look for that file you had an error in your path ... make sure you have a jar file in C:\Users\Harsh Jain\Downloads\com.mysql.jdbc_5.1.5.jar or C:\Users\Harsh Jain\Downloads\com.mysql.jdbc_5.1.5.jar\com.mysql.jdbc_5.1.5.jar (I'm thinking you might have copied the name of the jar file twice in your path).
2) If you have not manually downloaded that file, then you should do so. You can find that version at http://www.java2s.com/Code/Jar/c/Downloadcommysqljdbc515jar.htm (or elsewhere). Once downloaded, make sure to copy/unzip the actual JAR file to your C:\Users\Harsh Jain\Downloads folder.
Once you have ensured the file is actually on your system AND in the right path, run the build again.

Can't add the Mobile Apps Tracking bindings to my project

I'm trying to use the MAT bindings in my project however it seems that the .jar file is not included on: http://libgdx.badlogicgames.com/robovm-ios-bindings/
I have also tried adding it to my project by downloading the repository from: https://github.com/BlueRiverInteractive/robovm-ios-bindings/tree/master/mobileapptracking and adding the project to my Robovm build path but it's not working as well.
Any idea how to solve this ?
Thanks,
ASM
I have made a bindings project into a jar file doing the following. I am sure there is an easier way to get the framework in the correct folder, but I have not yet found it.
load bindings project in eclipse
export the source folder (you should get org/robovm/bindings/mobileapptracking/) to .jar file
open the jar file with winrar or similar program
add folder: robovm/ios/libs/ in META-INF folder
add the .framework(s) to this folder
now you should have a similar .jar file as on the libgdx site!

how to set solr requestHandler

data-config.xml
I add some setting infomation to solrconfig.xml,but show some error here:
how to set requestHandler???pls tell me how to set.thanks.
I don't know why shows this error.
"point:
org.apache.solr.common.SolrException:org.apache.solr.common.SolrException:
RequestHandler init failure"
Check to see if your RequestHandler class files are packaged properly in .jar file and they are located in the lib directory of your core or at the standard library location.
Make sure it's path is resolvable by the servlet container.
Check for other exceptions piled while initializing your RequestHandler.
Check for the log files inside the WebServer, for apche tomcat it is there in 'apache-tomcat-7.0.37\logs'.
Make sure you are not missing any dependencies to be included.
Paste your whole exception list for better glance of your problem.

Configuration path of Log4j2

I am trying to adopt Log4j2 to my project. Since my Java Application is packeted in a JAR file. I don't want "log4j2.xml" configuration packaged inside of JAR file. I am trying to learn how configuration file works from "http://logging.apache.org/log4j/2.x/manual/configuration.html"
But seems there is no clear instruction regarding altering the configuration file path of the Log4j2.
After googling about this topic I found something like "Referencing log4j config file within executable JAR" Referencing log4j config file within executable JAR, But this solution is not available any more according to "http://logging.apache.org/log4j/2.x/manual/migration.html" (if I understand it correctly).
So I am wondering if someone have any idea about this issue.
Thanks
You can set the system property to specify the configuration path.
set the
"-Dlog4j.configurationFile="D:\learning\blog\20130115\config\LogConfig.xml"
in VM arguments. replace
"D:\learning\blog\20130115\config\LogConfig.xml"
to your configuration path.
Put the log4j2.xml file in resource directory in your project so that the log4j will locate files under class path automatically.
Loading log4j2.xml file from the customized location-
You can use the System property/ VM arguments- Dlog4j.configurationFile=file:/path/to/file/log4j2.xml
This will work for any web application.
For some legacy applications, you can create a class for loading log4j2.xml/ log4j2.properties from the custom location on the machine like- D:/property/log4j2.xml
Using any of these approach,during application startup, the log4j2.xml file from the src/resources folder will be overridden by the custom location log4j.xml file.
Try using -Dlogging.config=Path_to_your_file