|
I use NetBeans IDE where every function is visually available. So you never need to use the cmd. You can download it for free.
|
|
|
|
|
KMAROIS wrote: How can I compile my java code without going to a DOS window?
by using an IDE...
the best I ever used is definitely Eclipse:
Eclipse for J2SE[^]
Eclipse for J2EE[^]
|
|
|
|
|
The RAD is better.
but not free.
|
|
|
|
|
Hi,
I've followed this article (http://java.sun.com/developer/technicalArticles/J2EE/AJAX/[^]) to create a Java Servlet and retrieve data from it using AJAX. In this example the doGet method is automatically run and it gives me the required output, however I would like to have additional methods in this class returning different things that I can call on demand, how would I do this?
Thanks in advance
|
|
|
|
|
Hi, I'm currently working on concerning a student record with guardians/parents... im using the java ee framework.. I'm having problems on retrieving the data on our database(MySQL).. Here is what i did.. i have created a class to retrieve those data from the database..
my problem is that whenever i retrieve that data in my jsp page, it only shows this Ljava.lang.String@123EGa something similar to this..
<small><br />
CLASS PLARENTS .. <br />
<br />
package com;<br />
import java.io.*;<br />
import java.sql.*;<br />
import javax.servlet.jsp.*;<br />
import javax.servlet.jsp.tagext.*;<br />
<br />
public class Parents {<br />
<br />
public String[] lastname;<br />
public String[] firstname;<br />
public String[] middlename;<br />
public String[] relation;<br />
<br />
private Connection connection = null;<br />
private Statement statement = null;<br />
private ResultSet rs = null;<br />
Connect con = new Connect();<br />
int count = 0;<br />
<br />
public Parents(){}<br />
<br />
public Parents(int idno) {<br />
int i = 0;<br />
try {<br />
Class.forName("com.mysql.jdbc.Driver").newInstance();<br />
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/sis",con.user,con.password);<br />
statement = connection.createStatement();<br />
rs = statement.executeQuery("SELECT * FROM guardians WHERE studidno='" + idno + "'");<br />
<br />
if (rs.last()) {<br />
count = rs.getRow();<br />
}<br />
<br />
lastname = new String[count];<br />
firstname = new String[count];<br />
middlename = new String[count];<br />
relation = new String[count];<br />
<br />
while (rs.next()){<br />
lastname[i] = rs.getString("lastname");<br />
firstname[i] = rs.getString("firstname");<br />
middlename[i] = rs.getString("middlename");<br />
relation[i] = rs.getString("relation");<br />
i++;<br />
}<br />
<br />
} catch (Exception e) {<br />
e.printStackTrace();<br />
}<br />
}<br />
<br />
<br />
public String[] getLastname(){return lastname;}<br />
<br />
public String[] getFirstname () {return firstname;}<br />
<br />
public String[] getMiddlename () {return middlename;}<br />
<br />
public String[] getRelation () {return relation;}<br />
<br />
}</small>
and this is what i placed in my jsp page..
<small> <% <br />
Parents p = new Parents(info.getIdno());<br />
for (int i = 0; i < p.getFirstname().length; i++ ) {<br />
%><br />
<tr bgcolor="#fefce3"><br />
<td><br />
<p id="info"><br />
<%= p.getLastname() %><br />
</p><br />
<p id="record">Relationship:<br />
<span id="relationship"><br />
<%= p.getFirstname() %><br />
</span><br />
</p><br />
</td><br />
<br />
</tr><br />
<tr><br />
<td> </td><br />
</tr><br />
>% } %></small>
Hi, I'm currently working on concerning a student record with guardians/parents... im using the java ee framework.. I'm having problems on retrieving the data on our database(MySQL).. Here is what i did.. i have created a class to retrieve those data from the database..
my problem is that whenever i retrieve that data in my jsp page, it only shows this Ljava.lang.String@123EGa something similar to this..
"according to what i have read on some searches, the best way to do it is by using data access objects..".. can anybody just an idea on how to do this using data access objects or give some sample codes for me to do this.. Im asking for an idea.. or any sample codes will do.. i have been working on this for about 2 days now, I've done so many researches and i haven't quite find any answer to my problem..
modified on Monday, October 27, 2008 9:23 PM
|
|
|
|
|
Hi,
I am a new member in this forum. I am developing a website.In my website once a user logs in, he is made to view a number of links, the click on which takes them to a new site.
suppose my site is x.com. x.com have a number of url, ome among is a.com. clicking on a.com should allow the user to access search page in a.com site. What i need is when a user clicks on the link a.com from my site x.com, he should be automatically logged into the a.com site. the login info, cookies etc should should be passed programmatically.
Can some one help me to implement this.
Thanks in advance
veda
|
|
|
|
|
Hi,
I have some problem in doing Jtable (I want the JTable to read the data from database) I wrote the code and it work with me in another project but Kow it didn't work I want some one to check this code if I miss some comma or thing in it.
The Code :
//=========================================
package Inventory;
public class cm1 {
private String tables;
public String selectData(String fields, String whereClause) {
if (whereClause == null && fields != null) {
return "SELECT " + fields + " FROM " + this.tables;
} else if (whereClause == null && fields == null) {
return " SELECT * FROM " + this.tables;
} else if (whereClause != null && fields == null) {
return " SELECT * FROM " + this.tables + " WHERE " + whereClause;
} else {
return "SELECT " + fields + " FROM " + this.tables + " WHERE "
+ whereClause;
}
}
//=========================================
public String deleteData(String whereClause) {
return "DELETE " + this.tables + " WHERE " + whereClause;
}
//=========================================
public void setDbTables(String table) {
this.tables = table;
}
//=========================================
public String insertQuery(AddPR p) {
return "INSERT INTO "
+ this.tables
+ " ( ITEMNUM,ITEMTYPE,LOCATION,MANUCODE,FXDASTNUM,MANUSRLNUM,COMMDATE,DESCRIPTION,STATUS,STATUSDATE,MODEL,MSRNUM,COMTYPE,USERNAME,TMSRV,PORT,IPADDRESS,PRICE,PRODUCTIONDATE,YEAR) VALUES ("+ p.getITEMNUM() + ", '" + p.getITEMTYPE() + "', '" + "', '" + p.getLOCATION() + "', '" + "','" + p.getMANUCODE() + "','" + p.getFXDASTNUM() + "', '" + p.getMANUSRLNUM() + "', '" + p.getCOMMDATE() + "', '" + p.getDESCRIPTION() + "', '" + p.getSTATUS() + "', '" + p.getSTATUSDATE() + "','" + p.getMODEL() + "','" + p.getMSRNUM() + "','" + p.getCOMTYPE() + "','" + p.getUSERNAME()+ "','" + p.getTMSRV() + "','" + p.getPORT()+ "','" + p.getIPADDRESS()+ "','" + p.getPRICE()+ "','" + p.getPRODUCTIONDATE() + "', '" +p.getYEAR();
}
}
//========================================="the end of the code"
please help me as soon as possible
|
|
|
|
|
Hi Xiang,
I found, your program for Searching and replacing strings (TextRep.java) in a file very usefull. Thanks for posting it.
Explaing below a scenario which im working on :
1. My Program should read the file name, search string and string to be replaced from an xml file.
<cmvc>
<cmvcauto>
<filename>C:\cmvc\Readme.txt</filename>
<string>Following are the contents of this CD.</string>
<replace>Im chnaged : Following are the contents of this CD.</replace>;
</cmvcauto>
</cmvc>
2. Get the file, search for the existence of the string in tht file , replace the old one with the new string and save modified file in a diff location.
I thought of modifying your program to match my requirement. Since your program TextRep.java also takes a backup of the file....my issue of saving the modified file is also solved. I have a program to get the values from the xml file. Now im passing those values to ur program instead of args[0], args[1] and args[2].
i get the value of filename from xml file in the fashion :
NodeList textFNList = firstNameElement.getChildNodes();
System.out.println("First file name : " +
((Node)textFNList.item(0)).getNodeValue().trim());
Now i define a method "replaceString" and call it in the main program by passing the values that i get from the xml file :
NodeList textFNList = firstNameElement.getChildNodes();
System.out.println("First file name : " +
((Node)textFNList.item(0)).getNodeValue().trim());
//-------
NodeList lastNameList = firstPersonElement.getElementsByTagName("string");
Element lastNameElement = (Element)lastNameList.item(0);
NodeList textLNList = lastNameElement.getChildNodes();
System.out.println("Search String : " +
((Node)textLNList.item(0)).getNodeValue().trim());
//----
NodeList ageList = firstPersonElement.getElementsByTagName("replace");
Element ageElement = (Element)ageList.item(0);
NodeList textAgeList = ageElement.getChildNodes();
System.out.println("Replace string " +
((Node)textAgeList.item(0)).getNodeValue().trim());
replaceString(((Node)textFNList.item(0)).getNodeValue().trim(), ((Node)textLNList.item(0)).getNodeValue().trim(), ((Node)textAgeList.item(0)).getNodeValue().trim());
Below is the method defenition and the defenition is your program :
public static void replaceString(String fileName, String match, String replacingString)
{
try
{
// make 32k buffer for output
StringBuffer strOutput = new StringBuffer(32768);
// read input file into a byte array
//byte[] pInput = ReadFile(args[0]); This is the original line from your program
byte[] pInput = ReadFile((filename);
// make a backup copy
WriteFile(fileName +".backup.copy",pInput);
String strInput = new String(pInput);
Doing this modification, i get the below error :
C:\Documents and Settings\Administrator\Desktop\CMVC_Automation>javac fullSearch.java
fullSearch.java:107: cannot find symbol
symbol : method ReadFile(java.lang.String)
location: class fullSearch
byte[] pInput = ReadFile(fileName);
^
fullSearch.java:109: cannot find symbol
symbol : method WriteFile(java.lang.String,byte[])
location: class fullSearch
WriteFile(fileName +".backup.copy",pInput);
^
2 errors
My program starts with these lines :
import org.w3c.dom.Document;
import org.w3c.dom.*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.io.*;
import java.util.*;
Would really apreciate, if you could help on those errors. Thanks.
|
|
|
|
|
Hi, I successfully send email with the following code in English. However, if the message and the subject title are in other characters, everything becomes question marks and the subject title says something like ...ANSI...3F=3F=3F...
How do I set the character encoding to utf-8, for example? Thanks.
<br />
try<br />
{ <br />
Properties props = new Properties(); <br />
Session sendMailSession; <br />
Transport transport; <br />
sendMailSession = Session.getInstance(props, null); <br />
props.put("mail.smtp.host", SMTP_CLIENT); <br />
Message newMessage = new MimeMessage(sendMailSession); <br />
newMessage.setFrom(new InternetAddress(EMAIL_FROM)); <br />
newMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(strEmail)); <br />
newMessage.setSubject(SUBJECT); <br />
newMessage.setSentDate(new Date()); <br />
strMsg = "Dear " + RS.getString("FIRST") + " " + RS.getString("LAST") + ",";<br />
strMsg += "\n\n";<br />
strMsg += [MESSAGE IN CHARACTERS OTHER THAN ASCII];<br />
newMessage.setText(strMsg); <br />
transport = sendMailSession.getTransport("smtp");<br />
transport.send(newMessage);<br />
} <br />
catch(MessagingException m) <br />
{ <br />
...<br />
}
|
|
|
|
|
Can anyone tell me different between JRE 1.6 and JRE 1.5? And what is "Keep temporary files on my computer" option? When I un-check this option, my applet runs ok. But If I check this option, my applet sometimes hangs up. So, I guess this error is come by "Keep temporary files on my computer" option. JRE 1.5 doens't have this option.
|
|
|
|
|
don't sun provide a Release Note Document ?
|
|
|
|
|
It can't help me in this error!
|
|
|
|
|
utnqbao wrote: It can't help me in this error!
which error ?
If sun can't help you with Java, I really wonder who can...
|
|
|
|
|
They don't tell this error. So, I can't find the solution of this error. Thanks for your reply!
I've another question. Do know you how to uncheck "Keep temporary files on my computer" by code or script?
|
|
|
|
|
utnqbao wrote: They don't tell this error. So, I can't find the solution of this error
but WHICH error ??!!
you're talking about an error, but I still don't know which.
do you have a message you could post here ?
|
|
|
|
|
Can anyone tell me different between JRE 1.6 and JRE 1.5? And what is "Keep temporary files on my computer" option? When I un-check this option (JRE 1.6.0_03), my applet runs ok. But If I check this option and clear caching, my applet sometimes hangs up at the first time. I get error below:
java.io.FileNotFoundException: http://loadbal1.amr.smtf.ds/netgcontent/NG/Content/NLS_Content/en_US_44003/en_US_44003_Sim2.nll
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at netg.util.nls_v.c(Unknown Source)
at netg.util.nls_u.a(Unknown Source)
at netg.InterNETgBase.c(Unknown Source)
at netg.InterNETgBase.a(Unknown Source)
at netg.nls_g5.actionPerformed(Unknown Source)
at netg.event.nls_bv.actionPerformed(Unknown Source)
at netg.display.nls_ay.a(Unknown Source)
at netg.display.nls_ck.a(Unknown Source)
at netg.display.nls_ay.a(Unknown Source)
at netg.display.nls_ck.a(Unknown Source)
at netg.display.nls_ay.a(Unknown Source)
at netg.display.nls_ck.a(Unknown Source)
at netg.display.nls_ay.a(Unknown Source)
at netg.display.nls_ck.a(Unknown Source)
at netg.display.nls_ay.a(Unknown Source)
at netg.display.nls_ck.a(Unknown Source)
at netg.display.nls_ay.a(Unknown Source)
at netg.display.nls_ck.a(Unknown Source)
at netg.display.nls_bt.a(Unknown Source)
at netg.display.nls_bt.a(Unknown Source)
at netg.display.nls_ay.a(Unknown Source)
at netg.display.nls_ck.a(Unknown Source)
at netg.display.nls_ck.a(Unknown Source)
at netg.display.nls_ck.a(Unknown Source)
at netg.display.nls_ck.a(Unknown Source)
at netg.display.nls_ck.a(Unknown Source)
at netg.display.nls_ck.a(Unknown Source)
at netg.display.nls_bd.a(Unknown Source)
at netg.display.nls_nr.run(Unknown Source)
at netg.util.nls_n.run(Unknown Source)
.............
From the second time, my applet is ok.
So, I guess this error is come by "Keep temporary files on my computer" option. JRE 1.5 doens't have this option. My applet can run ok with JRE 1.5.
Can you please tell me difference between check and un-check "Keep temporary files on my computer" option? Do we have anyway to uncheck it by Javascript or code? I don't know why un-check "Keep temporary files on my computer" option is ok with my Applet.
Thanks!
modified on Thursday, October 23, 2008 11:02 PM
|
|
|
|
|
We have developed a web-based application with JSP as front-end. Recently we observed that after taking one of the Windows Updates, few buttons in our application are not working. If I uninstall this particular update, buttons are working fine. When I say it is not working, it means that onclick action is not taking place.
Windows Update: KB956390
Also, our buttons are developed in VML.
I've given below some code snippets:
JSP
===
<html xmlns:zoniac="ZON">
.............
.............
.............
<zoniac:roundrect class="zoniac_roundButton" arcsize="0.9" fillcolor="#245f91" style='width:95px;cursor:hand' href="javascript:btnLinkClick('accountsNewCompany',document.accfrm)" strokecolor="#245f91" onselectstart="return false">New Account</zoniac:roundrect>
.............
.............
.............
</html>
Also, If I change the above "href" action into "onClick" event, it's working fine. But I want the action to be with href, since I cannot make this kind of change all over my application.
<zoniac:roundrect class="zoniac_roundButton" arcsize="0.9" fillcolor="#245f91" style='width:95px;cursor:hand' onClick="javascript:btnLinkClick('accountsNewCompany',document.accfrm)" strokecolor="#245f91" onselectstart="return false">New Account</zoniac:roundrect>
CSS
===
zoniac\:*
{ behavior: url(#default#VML)
}
.zoniac_roundButton
{ text-align:center;
padding-top:3px;
color:white;
font:bold 11px tahoma;
height:17px;
}
|
|
|
|
|
Anyone know where I can download this? I look on java.sun.com, but I didn't see it.
Everything makes sense in someone's mind
|
|
|
|
|
|
import javax.swing.JOptionPane;
public class MultiplicationTable {
public static void main(String[] args) {
String output = "Kilograms pounds";
output += "\n";
for (int j = 1 ; j <= 9; j+=2)
output += " " + j + "\n";
output += "\n";
for (double i = 2.2 ; i <=6.6 ; i+=4.4)
output += " " + i + "\n";
JOptionPane.showMessageDialog(null, output);
}
}
here is a clearer representation of my question.
im trying to get my second output column under pounds.
does anyone know how this would be done?
|
|
|
|
|
The code is right..
It prints ur second o/p under pounds only...
|
|
|
|
|
Hello,
I am kinda new to java.I was trying to create two text field in the code below with display and display1.But it wont show me two text field on GUI.
I could use some help from u guys.
Thanks and i appreciate it.
public class UserInterface
implements ActionListener
{
private CalcEngine calc;
private boolean showingAuthor;
private JFrame frame;
private JTextField display;
private JTextField display1;
private JLabel status;
/**
* Create a user interface for a given calcEngine.
*/
public UserInterface(CalcEngine engine)
{
calc = engine;
showingAuthor = true;
makeFrame();
frame.setVisible(true);
}
/**
* Make this interface visible again. (Has no effect if it is already
* visible.)
*/
public void setVisible(boolean visible)
{
frame.setVisible(visible);
}
/**
* Make the frame for the user interface.
*/
private void makeFrame()
{
frame = new JFrame(calc.getTitle());
JPanel contentPane = (JPanel)frame.getContentPane();
contentPane.setLayout(new BorderLayout(8, 8));
contentPane.setBorder(new EmptyBorder( 10, 10, 10, 10));
display = new JTextField();
display1 = new JTextField();
contentPane.add(display, BorderLayout.NORTH);
contentPane.add(display1, BorderLayout.EAST);
JPanel buttonPanel = new JPanel(new GridLayout(4, 4));
addButton(buttonPanel, "7");
addButton(buttonPanel, "8");
addButton(buttonPanel, "9");
addButton(buttonPanel, "C");
addButton(buttonPanel, "4");
addButton(buttonPanel, "5");
addButton(buttonPanel, "6");
addButton(buttonPanel, "?");
addButton(buttonPanel, "1");
addButton(buttonPanel, "2");
addButton(buttonPanel, "3");
buttonPanel.add(new JLabel(" "));
addButton(buttonPanel, "0");
addButton(buttonPanel, "+");
addButton(buttonPanel, "-");
addButton(buttonPanel, "=");
contentPane.add(buttonPanel, BorderLayout.CENTER);
status = new JLabel(calc.getAuthor());
contentPane.add(status, BorderLayout.SOUTH);
frame.pack();
}
|
|
|
|
|
Hi, my jsp page uses sun.net.smtp.SmtpClient to send email. It worked fine until the hosted location was moved to another server. Now it generates the sun.net.smtp.SmtpProtocolException and the hosting company can't find what's wrong with it so I'm here hoping somebody can help.
What could cause the SmtpProtocolException? "locahost" was what I used to connect to the smtp server. When it failed, I tried another smtp server like "mail.xxx.com" on another server and it worked but the problem is that this server can't let me send mail to other domains except its own domain.
Thanks
The following is the code responsible for the email:
-------------------------------------------------------------
try
{
client = new SmtpClient(localhost);
client.from(EMAIL_FROM);
client.to(strEmail);
PrintStream message = client.startMessage();
message.println("From: " + EMAIL_FROM);
message.println("To: " + strEmail);
message.println("Subject: " + SUBJECT);
message.println();
...
client.closeServer();
}
catch(IOException e)
{
<div><%=e%></div>
}
|
|
|
|
|
When I compile this, I get an error:
import java.lang.*;
import java.util.Scanner;
public class Test
{
public static void main(String[] args)
{
Scanner console = new Scanner(System.in);
}
}
The error is "Cannot resolve symbol class Scanner".
Anyone know what's wrong here?
Everything makes sense in someone's mind
|
|
|
|
|
don't know how you're compiling your code, but I have absolutely no error with the following code :
package test;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
}
}
|
|
|
|
|