|
Yes, probably. It's a trade off, whichever method you use will have a cost. You need to decide which is the better option for your application.
|
|
|
|
|
a very beginner question...
i'm a newbie in programming... just started java and read about packaging... i created i directory called firstproject and put a directory with one class inside of it and a FirstProject source file in the firstproject directory itself.
i made a class in that package directory that has a private string in it and tried to invoke from FirstProject source file but
getting compile error that the string is private...
i tried changing the string into protected or even public but still getting this error...
this is the class src file...
<pre lang="java">
package stickers;
public class Sticker
{
private String note;
Sticker(String note)
{
this.note = note;
}
public void displayNote()
{
System.out.println(note);
}
}
this is the FirstProject src file...
package firstproject;
import stickers.Sticker;
public class FirstProject
{
public static void main(String[] args)
{
Sticker sticker = new Sticker("hello sticky mehdi");
sticker.displayNote();
}
}
this is the actuall error:
error: Sticker(String) is not public in Sticker; cannot be accessed from outside package
|
|
|
|
|
You need to make your constructor public so other packages can access it:
public class Sticker
{
private String note;
public Sticker(String note)
{
this.note = note;
}
I would recommend going to The Java Tutorials[^] and working through them.
|
|
|
|
|
Hello there. I have managed to load and use c++ dll using JNI, in my java servlet (System.load). It works perfectly on first request I submit. But on subsequent requests, I get this weir d exception.
java.lang.UnsatisfiedLinkError: Native Library WEB-INF/lib/XXXXXX.dll already loaded in another classloader<br />
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1525)
Here is my loading code
public void init(ServletConfig config) throws ServletException
{
super.init(config);
ServletContext context = getServletContext();
String sMathDllpath = context.getInitParameter("MathDLLPath");
System.load(sMathDllpath);
}
I studied this tomcat wiki link and implemented their solution, among others, but could not succeed.
How do I implement it successfully? Thnks for anything you share.
|
|
|
|
|
You should declare it as a static action at class level like:
class ... {
static
{
System.loadLibrary("MathDLLPath");
}
}
That will ensure it is loaded when the class is first instantiated, but will only be loaded once.
|
|
|
|
|
Richard MacCutchan wrote: You should declare it as a static action at class level like:
I tried this just now. This is what I have
public class MainServlet extends HttpServlet
{
static{
System.loadLibrary("MathDll");
}
.........
}
And this is the exception I am getting
<br />
java.lang.UnsatisfiedLinkError: Native Library C:\Program Files\Java\jdk1.7.0_71\bin\MathDll.dll already loaded in another classloader<br />
What am I doing wrong now?
|
|
|
|
|
No idea, but it looks like you may have more than one call somewhere. Time to get the debugger out. Although, I have never used JNI in a servlet so it may be that there is something else happening.
|
|
|
|
|
Hello, I wanted to create a launcher for a game (Minecraft), but then I had an idea, that if I read some source codes that it would make it easier for me to make it, so I went searching for a source code , and I found one, but then I was testing it if it's working or not, and it opened, but then when I pressed launch after seconds it says that it couldn't update or something, I'm gonna put the source code file if you could please help me I'll appreciate that.
SKMCLauncher-fourth[^]
The error is
The following information can be provided to the developer:
com.sk89q.skmcl.LauncherException: Something went wrong while trying to update.
at com.sk89q.skmcl.launch.LaunchWorker.update(LaunchWorker.java:105)
at com.sk89q.skmcl.launch.LaunchWorker.call(LaunchWorker.java:141)
at com.sk89q.skmcl.launch.LaunchWorker.call(LaunchWorker.java:44)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "downloads" (Class com.sk89q.skmcl.minecraft.model.Library), not marked as ignorable
at [Source: java.io.StringReader@6738ae66; line: 21, column: 27] (through reference chain: com.sk89q.skmcl.minecraft.model.ReleaseManifest["libraries"]->com.sk89q.skmcl.minecraft.model.Library["downloads"])
at org.codehaus.jackson.map.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:53)
at org.codehaus.jackson.map.deser.StdDeserializationContext.unknownFieldException(StdDeserializationContext.java:267)
at org.codehaus.jackson.map.deser.std.StdDeserializer.reportUnknownProperty(StdDeserializer.java:673)
at org.codehaus.jackson.map.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:659)
at org.codehaus.jackson.map.deser.BeanDeserializer.handleUnknownProperty(BeanDeserializer.java:1365)
at org.codehaus.jackson.map.deser.BeanDeserializer._handleUnknown(BeanDeserializer.java:725)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:703)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:217)
at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:194)
at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:30)
at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
at org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:414)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2732)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1863)
at com.sk89q.skmcl.util.HttpRequest$BufferedResponse.asJson(HttpRequest.java:470)
at com.sk89q.skmcl.minecraft.MinecraftUpdater.installGame(MinecraftUpdater.java:166)
at com.sk89q.skmcl.minecraft.MinecraftUpdater.call(MinecraftUpdater.java:129)
at com.sk89q.skmcl.minecraft.MinecraftUpdater.call(MinecraftUpdater.java:53)
at com.sk89q.skmcl.launch.LaunchWorker.update(LaunchWorker.java:101)
... 6 more
|
|
|
|
|
Which area of Java has the greatest potential? Java security, web/mobile, telecommunications or data analytics?
|
|
|
|
|
Which area of Java has the greatest potential? Java security, web/mobile, telecommunications or data analytics?
|
|
|
|
|
None of us can foretell the future.
|
|
|
|
|
Security in any field will always be big, in my opinion.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi,
I have a Oracle DB in which all the information is stored and this information is been consumed by different teams and below is the two options i have to decide on :
1. Write a Stored procedure and give the stored procedure to the respective teams and they can call the stored procedure.
2. Write a stored procedure wrap it as an API and expose the API, different team will call the API exposed and API will in turn hit the SP and return the response to the team.
Like to know what is the PRON and CRONS with these options and what is the best possible solution to go with.
Thanks
|
|
|
|
|
|
Hello there. I am trying to get rid of scriptlets. I attach an object from servlet and try to access it in JSTL. But the logs say that JSP can not find the properties of this object. Here is the servlet sample
request.setAttribute("student", student);
Here is the JSTL sample, with different combinations - all producing no result at all (how ever scriptlets do)
<c:set var="student" value='${requestScope.student}' scope="request" />
<input type='text' value='${student.FirstName}' />
<input type='text' value='${student.FirstName}' />
<input type='text' value='<c:out value='${student.FirstName}' />' />
<input type='text' value=<c:out value='${student.FirstName}' /> />
As you can see, I have tried different combinations but could not get and display value of request attribute using JSTL. What is wrong? Thanks for any input.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
|
It is solved. Class was in default package. I put it in a package and import that Package.Class in JSP. works like a charm.
================
Hello there. I am attaching two variables with a HttpServletRequest request , an integer and an arraylist. After this when I forward request to a JSP, these casting issues arise. Here is the java servlet code
ArrayList<Employee> list_employees = m_objDbLayer.GetEmployeesAll();
int employee_count = list_employees.size();
request.setAttribute("employee_count", employee_count);
request.setAttribute("list_employees", list_employees);
RequestDispatcher dispatcher = request.getRequestDispatcher("/ViewEmployeesPage.jsp");
dispatcher.forward(request, response);
And here is the JSP code where I access these variables
<%@page import="java.util.ArrayList"%>
<%@page import="/WEB-INF/classes/Employee" %>
<!-- all the starting HTML tags here-->
<%
int employee_count= (int)request.getAttribute("employee_count");
out.println("Total Employees: " + employee_count);
ArrayList<Employee> list_users =new ArrayList<Employee>();
list_users = (ArrayList<Employee>)request.getAttribute("list_employees");
%>
I get these exceptions in server log
<br />
1- Cannot cast from Object to int<br />
2- Employee cannot be resolved to a type<br />
As you can see I am importing Employee class in JSP, what is wrong? Why it can not resolve Employee and convert from object to int? Thanks for any input.
modified 26-Aug-16 6:32am.
|
|
|
|
|
Hi All,
I am getting exception as Query result does not exist after calling the mehod QueryResults in drools.
qResults = kSession.getQueryResults ("results");
Is there any drools expert on coderanch who can help me to resolve the exception.
Please let me know if you need additional information.
Thanks,
|
|
|
|
|
The message is telling you what the problem is. The query named "results" cannot be found. Check your system settings, configuration etc, or wherever the queries are stored. See also https://docs.jboss.org/jbpm/v5.1/javadocs/org/drools/runtime/rule/WorkingMemory.html#getQueryResults(java.lang.String, java.lang.Object...).
|
|
|
|
|
i had wrote a code to connect to remote oracle data & execute query to find a task whether to check running or not...
I am getting the output in the console, but i need to print the console output to a file..
eg:
while(re.next){
executeing the query(select * from product_inventory_task)
acutally code connects to mutiple server & get the result.
while printing the result to text file ,it prints only the last value stored query reslut
|
|
|
|
|
Member 11427657 wrote: while printing the result to text file ,it prints only the last value stored query reslut So there is obviously a bug in your code. But since we cannot see your code we have no idea what that bug may be. I already gave you a suggestion to your previous post on this issue, at Re: how to write the console output to text file? - Java Discussion Boards[^]. Did you follow the link I provided?
|
|
|
|
|
|
I am a Java developer and I love Java to the core. I always wanted to learn the skills for creating web applications but never really got the time for it. But, lately I wanted to challenge myself to learn and create a web application. Now, here is the dilemma:-
I did some research before actually starting to develop the web application. I have narrowed my option down to two:- a. Use Java (learn JSP and servlets) - my heart is biased towards this approach. b. Use Python and Django framework - my mind is biased towards this approach. Now, I did some research on the Django framework and found a lot of positive reviews whereas I also found mixed reactions on the web regarding the use of Java for web applications. Consider me completely naive to the world of web applications as this will be my first time and it's nothing industry related or work. It's just a tool and knowledge that I want to learn.
I went on and followed some tutorials on Django but honestly, I din't really enjoy it that much but I am still open to giving it a shot.
So, my question is Will I be at a disadvantage if I create web applications using Java using the JSP and Servlets or should i follow the new trend of using Django and Python? Where could I miss the edge if I use Java over Python?
|
|
|
|
|
Rebecca1995 wrote: Will I be at a disadvantage if There is no way to answer such a question, beyond saying go with what you find interesting and enjoy. If you are looking to develop professional skills, then you need to research what skills are in demand where you live.
|
|
|
|
|
i think one should follow his heart instead of running behind trend.If u listen to your heart u will be more successful because u love what u r doing.Talking about java... It a wonderful language loved by many.and it will never face any crises for sure.so go for java..get mastery over it and concure the web world. to start with i will suggest
1. Get perfect in syntax
2. Create some sample project not so bulky but small
3. try to improve last done project by adding something new
4. imagine things around you which can be module in servlets and jsp format
5.try to find out market for your work done this will give you financial benefit and so you will get motivated to work harder
finally i wish almighty to give all the success
|
|
|
|