|
|
Thank you Sir for your kind help.
|
|
|
|
|
You're welcome!
|
|
|
|
|
Hello Guys!
First of all, i apologise for my English, but i'm Greek ... you know....
Today i start reading about java. i'm not a programmer and i don't know if this comunity can help in this case or if is for only programmers.
I think that Books, pdf's and youtube tutorials are useless for someone who want to learn programming.
So i started with Netbeans - UI, a simple window with 2 buttons.
One button must shut down the pc.
The other button in an "about" button. I want to press it and to have a window with a message that describes my first attempt to make a simple java application.
So, i designed the window, i program the first button to shut down my pc with this code i found on the internet :
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
Runtime runtime= Runtime.getRuntime();
try {
Process proc=runtime.exec("shutdown -s -t 0");
} catch (Exception ex) {
javax.swing.JOptionPane.showMessageDialog(null, ex.getMessage());
and now i want to create the "about" pop up message for the second button.
After that, i want to install and run this app on my pc AND I CAN'T UNDERSTAND HOW CAN I DO THIS.
Can you guys help me??
(i'm sorry if i'm off topic, but i really want to learn programming and i found the codeacademy - books - youtube tutorials ecc so useless. I want to learn this language creating real things in real windows with UI and run those things on my pc. I hate the "hello World" examples.)
|
|
|
|
|
|
|
A B C
A B C
A B C
This is my output.....
Please can you write the code for java.....
But one condition, only one inner and outer for loop is exist..
|
|
|
|
|
Sounds like homework.
Also sounds like you don't need for loops.
Ultimately it sounds like you're going to fail class...
|
|
|
|
|
System.out.println("A B C");
System.out.println("A B C");
System.out.println("A B C");
|
|
|
|
|
Hi ..
I am new to Java.. I will be getting image Byte array via CORBA.. In the Java Applet I should get the image data and write on to disk in Jpg format. I am trying with below code. but ImageIO.read() fails, no clue why? Could you please advise
I AccessController.doPrivileged(new PrivilegedAction() to make to that I has write access and tested writing text file, file is getting created.
But the issue was image is not getting created from byte array
Pleaes help
I just want to create image of any format from m_imgData[] and save it to disk. Thanks in advance !!
InputStream bteArrayInputStream = new ByteArrayInputStream(m_imgData);
final BufferedImage bufferedImage = ImageIO.read(bteArrayInputStream);
ImageIO.write(bufferedImage, "jpg", new File("c:\\temp\\myImg.jpg"));
|
|
|
|
|
Check the status of the read from the stream to see why it fails. I don't think anyone here would be able to guess.
|
|
|
|
|
|
http://localhost:8014/rp/WEB-INF/classes/rp/tr.java[^]
HTTP Status 404 - /rp/WEB-INF/classes/rp/tr.java
type Status report
message /rp/WEB-INF/classes/rp/tr.java
description The requested resource is not available.
--------------------------------------------------------------------------------
Apache Tomcat/8.0.28
|
|
|
|
|
How can anyone here access a link that goes to 'localhost'? Please edit your question and explain exactly what your problem is.
|
|
|
|
|
I have an existing Spring MVC maven project. Everything in the current project is exactly what I need as a template for a new Spring project. Is there any way I can use the existing project as a template and rename it to a new project without changing anything but the name. I tried to recreate the existing project from scratch and just add the same existing components but am running into a lot of problems with the dependencies and other jar files as well as configurations.
|
|
|
|
|
I got it. All I did was select copy from the file menu and then it allowed me to rename it.
|
|
|
|
|
I need to add multiple controllers to my Spring MVC project which only has one right now. My current project only has one SpringDispatcher in the web.xml and it maps the <url-pattern>/</url-pattern> to the '/' of the controller's @RequestMapping(value = "/") controller request mapping. Because everything is in the web.xml and there are no other xml files that do any dispatcher mapping, should I not be able to just add a new <url-pattern>/</url-pattern> with a different controller pattern to the web.xml? Below are the web.xml and the one working controller.
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>SpringMvcJdbcTemplate</display-name>
<context-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>SpringDispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>net.codejava.spring</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SpringDispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
HomeController.java
package net.codejava.spring.controller;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import net.codejava.spring.dao.ContactDAO;
import net.codejava.spring.dao.ContactDAODS;
import net.codejava.spring.model.Contact;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
/**
* This controller routes accesses to the application to the appropriate
* hanlder methods.
* @author www.codejava.net
*
*/
@Controller
public class HomeController {
@Autowired
private ContactDAO contactDAO;
@Autowired
private ContactDAODS contactDAODS;
@RequestMapping(value = "/")
public ModelAndView login() {
Contact contact = new Contact();
ModelAndView model = new ModelAndView("login");
model.addObject("contact", contact);
return model;
}
@RequestMapping(value = "/loginContact", method = RequestMethod.POST)
public ModelAndView loginContact(@ModelAttribute Contact loginContact) {
ModelAndView model;
Contact contact = contactDAO.login(loginContact);
if(contact != null)
{
model = new ModelAndView("menu");
return model;
}
else
{
Map<String, String> message = new HashMap<String, String>();
message.put("message", "Login password error");
//Message message = new Message();
//message.MessageText = "Login Error";
model = new ModelAndView("loginError");
model.addObject("message", message);
return model;
}
}
@RequestMapping(value = "/menuContact", method = RequestMethod.GET)
public ModelAndView menu(ModelAndView model){
model.setViewName("menu");
return model;
}
@RequestMapping(value = "/listContact", method = RequestMethod.GET)
public ModelAndView listContact(ModelAndView model) throws IOException{
List<Contact> listContact = contactDAO.list();
model.addObject("listContact", listContact);
model.setViewName("home");
return model;
}
@RequestMapping(value = "/newContact", method = RequestMethod.GET)
public ModelAndView newContact(ModelAndView model) {
Contact newContact = new Contact();
model.addObject("contact", newContact);
model.setViewName("ContactForm");
return model;
}
@RequestMapping(value = "/saveContact", method = RequestMethod.POST)
public ModelAndView saveContact(@ModelAttribute Contact contact) {
contactDAO.saveOrUpdate(contact);
return new ModelAndView("redirect:/");
}
@RequestMapping(value = "/deleteContact", method = RequestMethod.GET)
public ModelAndView deleteContact(HttpServletRequest request) {
int contactId = Integer.parseInt(request.getParameter("id"));
contactDAO.delete(contactId);
return new ModelAndView("redirect:/");
}
@RequestMapping(value = "/editContact", method = RequestMethod.GET)
public ModelAndView editContact(HttpServletRequest request) {
int contactId = Integer.parseInt(request.getParameter("id"));
Contact contact = contactDAO.get(contactId);
ModelAndView model = new ModelAndView("ContactForm");
model.addObject("contact", contact);
return model;
}
@RequestMapping(value="/showContact")
public ModelAndView getContact(ModelAndView model) throws IOException{
Contact contact = contactDAODS.get((Integer)25);
model.addObject("contact", contact);
model.setViewName("ContactSP");
return model;
}
}
|
|
|
|
|
Provide solution with code?
|
|
|
|
|
No.
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
We are not here to provide you with "solution with code" - that is supposed to be your job as part of your grade.
Try it yourself, you may find it is not as difficult as you think!
If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
no sir i m asking how can i relate my theory examples to industry level so here many are working thats why i asked sir?
|
|
|
|
|
//hierarchial inheritance
class Polygon
{
double height;
double width;
public void set_values(double a,double b)
{
height=a;
width=b;
}
}
class Rectangle extends Polygon
{
double area()
{
return height*width;
}
}
class Triangle extends Polygon
{
double area()
{
return (height*width)/2;
}
}
class AreaClass
{
public static void main(String[] args)
{
Rectangle obj1=new Rectangle();
Triangle obj2=new Triangle();
obj1.set_values(10,10);
obj2.set_values(10,10);
//obj1.Rectangle();
//obj1.Triangle();
System.out.println("Area of rectangle is "+obj1.area());
System.out.println("Area of Triangle is "+obj2.area());
}
}
// so sir i know the concept but i m not able to get how exactly this will be applied in industry so please provide some example then i will think and try to solve that kind of problems
|
|
|
|
|
SSHASHIDHAR wrote: how exactly this will be applied in industry Impossible to say, since the code without detailed explanation does not mean a lot. What problem is it supposed to solve?
|
|
|
|
|
Sir actually i have taken that as one simple inheritance program so i can write such theoretical programs but i wanted to know how in industry that inheritance is helpful i mean if u give some clarity then i can able to solve.
|
|
|
|
|
SSHASHIDHAR wrote: if u give some clarity then i can able to solve. Solve what? You have not defined a problem. As far as using your code in "industrial level" situations, it may well be useful, but you need to find the problem first, before you can apply the code to it.
|
|
|
|
|
I have an existing MVC application that uses the following Dispatcher:
<servlet-mapping>
<servlet-name>SpringDispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
What I did was under the WEB-INF/views directory add a menu.jsp file to be the new startup jsp.
/SpringMvcJdbcTemplate/WEB-INF/views/menu.jsp
New menu.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<div align="center">
<h1>Main Menu</h1>
<h3><a href="listContact">List Contacts</a></h3>
</div>
</body>
</html>
Now what I did is change the initial "/" RequestMapping controller method to look like the following:
@RequestMapping(value = "/", method = RequestMethod.GET)
public ModelAndView menu(ModelAndView model){
model.setViewName("menu");
return model;
}
Now I feel that everything should work but when I run the application I receive the following page errors:
HTTP Status 404 - /SpringMvcJdbcTemplate/WEB-INF/views/menu.jsp
type Status report
message /SpringMvcJdbcTemplate/WEB-INF/views/menu.jsp
description The requested resource is not available
I am not sure what I am doing wrong. Can anyone help?
|
|
|
|