Assistance needed with simple java vocabulary program
I need to construct a java program that can read in text documents. The program must then display an image and prompt the user to input the word that best-describes the image. If the user is incorrect, however, the program must tell the user how many letters the word has and what the first letter is.
* @(#)words.java
* @author
* @version 1.00 2010/6/8
import javax.swing.*; //class necessary for GUI
import java.awt.*; //class necessary for GUI
import java.awt.event.*; //class necessary for GUI
import java.util.ArrayList; //import ArrayList class
public class Words implements ActionListener { //ActionListener is required for the button to function
//initialize values that will be used in other methods
int noLetters = 0; //number of letters
String[] words; //words
JTextField textNL; //inputs number of letters
ArrayList<JLabel> list;
public static void main (String[] args) {
Word s = new Word(); //this is so you are not referencing non-static methods from a static context (main must be static, but the constructor is not)
s.go();} //runs following method as a method of the object Words s
public void go() {
//build GUI
JFrame frame = new JFrame(); //intializes frame, this is essentially the GUI
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //sets program to stop when frame is exited
JTabbedPane pane = new JTabbedPane(); //creates a new tabbed panel
JPanel panel1 = new JPanel(); //creates input panel
JPanel panel2 = new JPanel(); //creates output panel
textNL = new JTextField("", 15); //initializes the text field of the same name from the beginning of the program
JButton button = new JButton("Enter"); //This button will input the data you have entered into the text fields
button.addActionListener(this); //tells the button to do stuff when it is clicked (see actionPerformed())
panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS)); //Sets frame to display labels and text fields arranged vertically
panel1.add(new JLabel("Number of Letters")); //this label tells you what the text field is prompting for
panel1.add(textND); //adds text field to input panel
panel1.add(BorderLayout.SOUTH, button); //adds button to input panel
pane.add("Enter Data", panel1); //adds input panel to tabbed panel
pane.add("Words", panel2); //adds output panel to tabbed panel
frame.getContentPane().add(pane); //adds tabbed panel to frame
frame.setSize(400, 400); //sets GUI intial dimensions
frame.setVisible(true); //displays GUI
//end of GUI build
}
Similar Messages
-
Assistance needed with small program for non-profit
Energy Cycle is a small non-profit based in Virginia. We are using labview for a project that monitors 20 dc generators. Looking for someone who might be able to donate a modest amount of time and help us out.
I have 20 years of LabVIEW Experience and I have developed a LabVIEW based HTML5 WebSockets Server that works with simple JavaScript HTML5 WebSockets Clients on Mobile Devices like iPhone/iPod/iPad and Android Phone/Tablet devices. I would be willing to help you out.
I keep a LabVIEW Demo WebSockets Server I have developed running on my desktop online and here is a link to a JavaScript iPhone Simulator I wrote that runs a WebSocket Client Demo I wrote that can be checked out: http://invbapp.com/iPhoneSimulator
Note: Run this in the Chrome Browser because it fully supports HTML5 WebSockets! Also, this demo is a single client version and if a new client connects while you are on, it will knock you off, I am working on a multi-client version.
I bring this up because this sort of technology could be integrated into products or systems to allow control and monitoring from devices like their iPhone.
Best Regards,
George Miles
INVENTEERING, Inc.
317 South 4th Street, Unit 329
La Crosse, WI 54601
Tel: 608-498-4982 or 858-926-5927
Skype:skype.gmiles (Free Internet Video Phone requires Skype™ Software)
Email: [email protected]
Website: http://www.inventeering.com -
Help needed with JNI - java.lang.UnsatisfiedLinkError
I need some help with JNI. I am running on Sun Solaris 7 using their CC compiler. I wrote a simple java program that calls a native method to get a pid. Everything work until I use cout or cerr. Can anyone help? Below is what I am working with.
Note: The application works. The problem is when the C++ code tries to display text output.
My error log is as follows:
java Pid
Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/dew/test/libPid.so: ld.so.1: /usr/j2se/bin/../bin/sparc/native_threads/java: fatal: relocation error: file /home/dew/test/libPid.so: symbol __1cDstdEcerr_: referenced symbol not found
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1382)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1306)
at java.lang.Runtime.loadLibrary0(Runtime.java:749)
at java.lang.System.loadLibrary(System.java:820)
at Pid.<clinit>(Pid.java:5)
Pid.java
========
* Pid: Obtains the pid from the jvm.
class Pid {
static { System.loadLibrary("Pid"); }
public native int getPid();
public static void main(String args[])
System.out.println("Before construction of Pid");
Pid z = new Pid();
System.out.println(z.getPid());
z = null;
Pid.cpp
=========
* Native method that obtains and returns the processid.
#include "Pid.h"
#include "unistd.h"
#include <iostream.h>
JNIEXPORT jint JNICALL Java_Pid_getPid(JNIEnv *env, jobject obj) {
/* cout << "Getting pid\n"; */
cerr << "Getting pid\n";
/* printf("Getting pid\n"); */
return getpid();I forgot to include my build information.
JAVA_HOME = /usr/j2se/
LD_LIBRARY_PATH = ./:/opt/readline/lib:/opt/termcap/lib:/usr/bxpro/xcessory/lib:/${JAVA_HOME}/lib:/usr/RogueWave/workspaces/SOLARIS7/SUNPRO50/0d/lib:/usr/RogueWave/workspaces/SOLARIS7/SUNPRO50/3d/lib:/usr/sybase/lib
javac Pid.java
javah Pid
CC -G -I${JAVA_HOME}/include -I${JAVA_HOME}/include/solaris Pid.cpp -o libPid.so
Thanks again,
Don -
Using RDF XML output with custom java concurrent program.
Hi, I started investigating the java API and did not find the way to use RDF XML output ? The goal is to use the Bursting engine to send out PDF generated from a "RDF XML" and a RTF template.
Is there someone that could help be with this ?
ThanksHi Jacky
Im looking to write a paper on this subject.
Basically you can write a java conc program that will take the XML output from the Oracle Report and burst it. So you could tackle it a couple of ways.
1. Have the JCP call the Oracle Report, sit and wait for it to complete then call the bursting engine with the XML and the control file. this has the advantage that its a single step for users to submit the report on the other hand you'll be writing a JCP specifically for that report.
2. Write a generic JCP that can burst any XML, a little tougher to write but will have applications all over the Apps suites.
Regards, Tim -
Hi there,
In my project, I have several squares. When the mouse is hovered over these squares, I want them to change colour and when the mouse is taken away, I want them to change back. I managed to achieve this by creating copies of the squares with a different colour, and then showing and hiding appropriately with simple show and hide code, but this caused some problems. Therefore, I am wondering if this can be done via code, perhaps with the :hover CSS selector, or some other means. If so, I would be deeply gratified to know how this could be done.
Many thanks,
Dee RobertsHi there, hopefully this will help you out, note that the object who's color we're changing btn.RectangleShape in my example below) has to be a simple shape div in Edge, it can't be a symbol.
Example:
www.timjaramillo.com/code/edge/rollover3_gsap_colorChange
Source:
www.timjaramillo.com/code/edge/_source/rollover3_gsap_colorChange.zip
// code on Stage.document.compositionReady:
// load GSAP anim library
yepnope(
nope:[
'greensock/TweenMax.min.js',
'greensock/easing/EasePack.min.js',
'greensock/plugins/CSSPlugin.min.js',
'greensock/plugins/ColorPropsPlugin.min.js'
complete: init
//when yepnope has loaded everything execute init();
function init (){
var coloredSquare = sym.getSymbol("btn").$("RectangleShape");
sym.$("btn").mouseenter(function(){
TweenMax.to(coloredSquare, 1, {backgroundColor:"#938461", ease:Power2.easeIn});
sym.$("btn").mouseleave(function(){
TweenMax.to(coloredSquare, 1, {backgroundColor:"#000000", ease:Power2.easeIn}); -
Help needed with operating java on other programs
I have a fairly difficult (I think) question.
I am trying to create a program to enact itself on other programs.
It needs to perform 4 functions.
1) Open an exe (such as notepad)
2) Use the exe to open another file (such as a .txt)
3) Find the color of a specific pixel on the screen (ie, (300,800)) and
4) Pull a number from a field in the program
I would apprieciate any help on this, whether in the form of an answer, or a url that could help me with it.
thanksyou could try shell commands to the dos prompt like:
try {
Properties systemProps = System.getProperties();
String osVersion = systemProps.getProperty("os.name");
if (osVersion.equals("Windows 98")) {
Runtime.getRuntime().exec("start \"notepad"");
else if (osVersion.equals("Windows 95")) {
Runtime.getRuntime().exec("start \"notepad"");
else { // win nt (2000 or xp)
Runtime.getRuntime().exec("cmd.exe /c notepad");
}catch(IOException err) {}Or locate the notepad.exe and use the runtime class to launch it, to open a txt file is exactly the same but substitute the txt file name instead of notepad, that should launch notepad and open the txt in it, if you mean open notepad and then control it and open a file, that java can?t do, need another language to do it or work with another language and java together. Not sure about the rest, -
I'm a complete novice with Java. I want to write a Java program to run on Windows 2000 servers to write a list of certain files in a directory into a *.txt file. I hope to add complexity once I have this basic part working. Here's the code I have so far:
//this Java application finds poll* files
public class FindPollApp
//Create File Object
File dir = new File("d:/jda/windss/poll");
//List directory
if(dir.isDirectory())
String[] dirContents = dir.list();
for (int i=0; i < dirContents.length; i++)
System.out.println(dirContents);
//Iterate through files
I get the following errors:
C:\JAVA>javac FindPollApp.java
FindPollApp.java:9: illegal start of type
if(dir.isDirectory())
^
FindPollApp.java:18: <identifier> expected
^
2 errors
Thanks.I'm a complete novice with Java. I want to write a
Java program to run on Windows 2000 servers to write
a list of certain files in a directory into a *.txt
file. I hope to add complexity once I have this
basic part working. Here's the code I have so far:
//this Java application finds poll* files
public class FindPollApp
//Create File Object
File dir = new File("d:/jda/windss/poll");
//List directory
if(dir.isDirectory())
String[] dirContents = dir.list();
for (int i=0; i < dirContents.length; i++)
System.out.println(dirContents);
//Iterate through files
I get the following errors:
C:\JAVA>javac FindPollApp.java
FindPollApp.java:9: illegal start of type
if(dir.isDirectory())
^
FindPollApp.java:18: <identifier> expected
^
2 errors
Thanks.
You need to create a method and insert your if statement in there -
Need Help w/ Java Applet Program
Hello, first time on fourms. I've taken one year of Java(Poorly instructed) and I am currently trying to build a simple program, my brother is a really good gymnast so the object of this program is two drop down menus with selections, and based on the selections, an output. It has been a while since i've done anything, i've looked for reference at old work i've done and I just have gotten lost, I just need a few pointers. I'm also having compile problems such as, "Cannot find symbol", it is frustrating me, any help would be greatly appreciated!
Here is what i've got so far, based on the above "requirements" can anyone help me out? PS. The odd names I gave them are based on another similar program I wrote a while back. Thanks again!
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
public class gymnastics extends JFrame
private JComboBox equationTypeComboBox;
private JComboBox equationTypeComboBox2;
private JTextField answerTextField;
public gymnastics()
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setUpInfoPanel();
setUpInfoPanel2();
setUpEquationPanel();
setSize(300,340);
answerTextField.requestFocus();
private void setUpInfoPanel()
JPanel infoPanel = new JPanel();
infoPanel.setLayout(new BoxLayout(infoPanel, BoxLayout.Y_AXIS));
JPanel typePanel = new JPanel();
typePanel.add(new JLabel("Event type: "));
equationTypeComboBox = new JComboBox("Floor", "Pommel", "Vault", "Rings", "PBars", "High Bar");
typePanel.add(equationTypeComboBox);
infoPanel.add(typePanel);
getContentPane().add(infoPanel, BorderLayout.NORTH);
private void setUpInfoPanel2()
JPanel infoPanel2 = new JPanel();
infoPanel2.setLayout(new BoxLayout(infoPanel2, BoxLayout.Y_AXIS));
JPanel typePanel = new JPanel();
typePanel2.add(new JLabel("Group Code: "));
equationTypeComboBox2 = new JComboBox("I","II","III","IV","V");
typePanel.add(equationTypeComboBox2);
infoPanel.add(typePanel);
getContentPane().add(infoPanel2, BorderLayout.CENTER);
public void setUpEquationPanel();
equationPanel.add(new JLabel("Output: "));
answerTextField = new JTextField();
answerTextField = ("Test Output");
equationPanel.add(answerTextField);
getContentPane().add(equationPanel, BorderLayout.SOUTH);
public static void main(String args[])
new gymnastics().setVisible(true);
}Sorry about the code problem and thanks for the encouragement, it is just a bit frustrating at times.
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
public class gymnastics extends JFrame
private JComboBox equationTypeComboBox;
private JComboBox equationTypeComboBox2;
private JTextField answerTextField;
public gymnastics()
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setUpInfoPanel();
setUpInfoPanel2();
setUpEquationPanel();
setSize(300,340);
answerTextField.requestFocus();
private void setUpInfoPanel()
JPanel infoPanel = new JPanel();
infoPanel.setLayout(new BoxLayout(infoPanel, BoxLayout.Y_AXIS));
JPanel typePanel = new JPanel();
typePanel.add(new JLabel("Event type: "));
equationTypeComboBox = new JComboBox("Floor", "Pommel", "Vault", "Rings", "PBars", "High Bar");
typePanel.add(equationTypeComboBox);
infoPanel.add(typePanel);
getContentPane().add(infoPanel, BorderLayout.NORTH);
private void setUpInfoPanel2()
JPanel infoPanel2 = new JPanel();
infoPanel2.setLayout(new BoxLayout(infoPanel2, BoxLayout.Y_AXIS));
JPanel typePanel = new JPanel();
typePanel2.add(new JLabel("Group Code: "));
equationTypeComboBox2 = new JComboBox("I","II","III","IV","V");
typePanel.add(equationTypeComboBox2);
infoPanel.add(typePanel);
getContentPane().add(infoPanel2, BorderLayout.CENTER);
public void setUpEquationPanel();
equationPanel.add(new JLabel("Output: "));
answerTextField = new JTextField();
answerTextField = ("Test Output");
equationPanel.add(answerTextField);
getContentPane().add(equationPanel, BorderLayout.SOUTH);
public static void main(String args[])
new gymnastics().setVisible(true);
} -
Simple Java 3D programs CPU Usage spikes to up to 90 percent!
Hi, everyone. Im completely new to Java 3D and Im toying around with basic program structure right now. My code is based off of that in the first chapter on 3D in Killer Game Programming in Java. I removed most of the scene elements, replacing them with a simple grid, Maya style. (Yes, Im starting off small, but my ambitions are grand I intend on creating a polygonal modeling and animation toolset. After all, the Maya PLE is dead damn you, Autodesk! and I just plain dislike Blender.) I implement a simple OrbitBehavior as a means for the user to navigate the scene. That part was basically copy and paste from Andrew Davisons code. The mystery, then, is why the programs framerate drops below 1 FPS and its CPU Usage spikes to up to 90 percent, according to the Task Manager, when I tumble the scene. Id appreciate anyone taking the time to look at the code and trying to identify the problem area. (Ive undoubtedly missed something totally newbish. -.-) Thank you!
(Also, I had the worst possible time wrestling with the posting process. Is anyone else having trouble editing their posts before submitting them?)
import java.awt.*;
import javax.swing.*;
public class MAFrame
public static final Dimension SCREEN_SIZE = Toolkit.getDefaultToolkit().getScreenSize();
public MAFrame ()
System.out.println("Initializing...");
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
catch (Exception e) {
e.printStackTrace();
JFrame frame = new JFrame ("Modeling and Animation");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MAViewPanel panel = new MAViewPanel ();
frame.getContentPane().add(panel);
frame.pack();
frame.setLocation(((int)SCREEN_SIZE.getWidth() / 2) - (frame.getWidth() / 2),
((int)SCREEN_SIZE.getHeight() / 2) - (frame.getHeight() / 2));
frame.setVisible(true);
import com.sun.j3d.utils.behaviors.vp.*;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import java.awt.*;
import javax.media.j3d.*;
import javax.swing.*;
import javax.vecmath.*;
public class MAViewPanel extends JPanel
public static final int GRID_SIZE = 12;
public static final int GRID_SPACING = 4;
public BoundingSphere bounds;
public BranchGroup sceneBG;
public SimpleUniverse su;
public MAViewPanel ()
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D (config);
canvas3D.setSize(600, 600);
add(canvas3D);
canvas3D.setFocusable(true);
canvas3D.requestFocus();
su = new SimpleUniverse (canvas3D);
createSceneGraph();
initUserPosition();
orbitControls(canvas3D);
su.addBranchGraph(sceneBG);
public void createSceneGraph ()
sceneBG = new BranchGroup ();
bounds = new BoundingSphere (new Point3d(0, 0, 0), 1000);
// ambient light
Color3f white = new Color3f (1.0f, 1.0f, 1.0f);
AmbientLight ambientLight = new AmbientLight (white);
ambientLight.setInfluencingBounds(bounds);
sceneBG.addChild(ambientLight);
// background
Background background = new Background ();
background.setColor(0.17f, 0.65f, 0.92f);
background.setApplicationBounds(bounds);
sceneBG.addChild(background);
// grid
createGrid();
sceneBG.compile();
public void createGrid ()
Shape3D grid = new Shape3D();
LineArray lineArr = new LineArray (GRID_SIZE * 8 + 4, GeometryArray.COORDINATES);
int offset = GRID_SIZE * GRID_SPACING;
// both sides of the grid plus the middle, done for both directions at once (each line defined by two points)
for (int count = 0, index = 0; count < GRID_SIZE * 2 + 1; count++) {
// vertical, left to right
lineArr.setCoordinate(index++, new Point3d (-offset + (count * GRID_SPACING), 0, offset)); // starts near
lineArr.setCoordinate(index++, new Point3d (-offset + (count * GRID_SPACING), 0, -offset)); // ends far
// horizontal, near to far
lineArr.setCoordinate(index++, new Point3d (-offset, 0, offset - (count * GRID_SPACING))); // starts left
lineArr.setCoordinate(index++, new Point3d (offset, 0, offset - (count * GRID_SPACING))); // ends right
grid.setGeometry(lineArr);
sceneBG.addChild(grid);
public void initUserPosition ()
ViewingPlatform vp = su.getViewingPlatform();
TransformGroup tg = vp.getViewPlatformTransform();
Transform3D t3d = new Transform3D ();
tg.getTransform(t3d);
t3d.lookAt(new Point3d (0, 60, 80), new Point3d (0, 0, 0), new Vector3d(0, 1, 0));
t3d.invert();
tg.setTransform(t3d);
su.getViewer().getView().setBackClipDistance(100);
private void orbitControls (Canvas3D c)
OrbitBehavior orbit = new OrbitBehavior (c, OrbitBehavior.REVERSE_ALL);
orbit.setSchedulingBounds(bounds);
ViewingPlatform vp = su.getViewingPlatform();
vp.setViewPlatformBehavior(orbit);
}Huh. A simple call to View.setMinimumFrameCycleTime() fixed the problem. How odd that there effectively is no default maximum framerate. Of course simple programs like these, rendered as many times as possible every second, are going to consume all possible CPU usage...
-
Help Needed With A Java Installation
Hello,
I'm beyond being a novice with regards to Java. To be quite honest, I don't have the time right now to learn the language, nor do I have the need for anything other than what I am about to ask. I say this upfront to avoid unfriendly comments from people who may criticize my "laziness", NOT to sound disrespectful to those who post or answer questions in this forum.
With that said, here's my question...
I have a Sun/Cobalt RaQ4i server. I'd like to run a few free license Java games that I found on a website. The problem is, RaQ appliances do not ship with Java installed. I've been looking for some way to get it on my server for a few days now, with little luck. I've searched the Java help forums, the Sun/Cobalt forums and a few other help sites such as www.raqzone.com. (...which is why laziness is in quotes up there.) I did find this page... "http://developer.cobalt.com/java/java.raq.php". I have now installed both, the package and the update, on the server. However, the applet still does not run. I don't need the JSP feature, as my site is done in ASP. I don't know what a servlet is, but thought it might be similar to an applet, and would do the trick. *?* Apparently, I was wrong. Can ANYONE tell me what I need to do to get the desired results when I try to run a Java applet on my Cobalt RaQ?? I'd also be willing to be a fee to have it installed... correctly, of course! :)
Thanks in advance for any directions or guidance,
-Daniel
[email protected]Assuming you're running Solaris, you can download the Java Runtime Environment (JRE) from http://java.sun.com/
One of the provided programs is appletviewer, which you will be able to use to run applets if they are on your local machine. I'm not entirely sure about Solaris, but the JRE may also install the Java Plugin to your browser so you can view applets in the browser.
Apologies if this was already mentioned in the link you provided - registration/login is required, so I didn't read it.
I hope you have more luck with your applets,
-Troy -
How to run the simple java card program in eclipse?
I am trying to run a simple HelloWorld program in eclipse 3.5 having java card development kit 2.2 installed in it.
Firstly,I go to the JCWDE tab and press start..then when trying to deploy that package its giving me error like " com.hw.HelloWorld: unsupported class file format of version 50.0." can any one help me in this what is this error???n how to resolve n run this program..Hi,
It is because the converter works on byte code and it only supports a subset of the Java language (see the JC specifications). It is kind of like compiling you code on Java 6 and trying to run it on Java 5. The JCDK outlines the required compiler version.
Cheers,
Shane -
Hi, i have written a simple code to send mail thru java... but it doesnt work... control never comes back after stepping in to the send function.. no exceptions.. no mails sent.. nothin.. cud someone hel me out??
sometimes i get this exception after a long time:
javax.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketException: Connection reset
at com.sun.mail.smtp.SMTPTransport.readServerResponse(Unknown Source)
at com.sun.mail.smtp.SMTPTransport.openServer(Unknown Source)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(Unknown Source)
at javax.mail.Service.connect(Unknown Source)
here is the code snippet:
public void mySend() throws Throwable
Properties p = System.getProperties();
p.put("mail.transport.protocol", "smtp");
p.put("mail.smtp.host", "smtp.gmail.com");
p.put("mail.smtp.port", "465");
p.put("mail.smtp.starttls.enable", "true");
p.put("mail.smtp.auth", "true");
Authenticator authenticator = new Authenticator()
protected PasswordAuthentication getPasswordAuthentication()
return new PasswordAuthentication("vicky.bhandari", "password");
Session session = Session.getInstance(p, authenticator);
SMTPMessage message = new SMTPMessage(session);
InternetAddress fromAddress = new InternetAddress("[email protected]");
InternetAddress toAddress = new InternetAddress("[email protected]");
message.setSubject("Test");
message.addRecipient(Message.RecipientType.TO, toAddress);
message.setFrom(fromAddress);
SMTPTransport.send(message);
Could someone please help me out??Hey,
Im currently having problems with the code below:
public class SendMail {
private static final String SMTP_HOST_NAME = "smtp.gmail.com";
private static final String SMTP_AUTH_USER = "[email protected]";
private static final String SMTP_AUTH_PWD = "**************";
public void sendMail(String recipients[ ], String subject, String message , String from) throws MessagingException{
boolean debug = false;
Properties props = System.getProperties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.smtp.port", "465");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.auth", "true");
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getDefaultInstance(props, auth);
session.setDebug(debug);
Message msg = new MimeMessage(session);
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
InternetAddress[] addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++)
addressTo[i] = new InternetAddress(recipients);
msg.setRecipients(Message.RecipientType.TO, addressTo);
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport tr = session.getTransport("smtp");
tr.connect(SMTP_HOST_NAME, SMTP_AUTH_USER, SMTP_AUTH_PWD);
msg.saveChanges(); // don't forget this
//tr.sendMessage(msg, msg.getAllRecipients());
tr.close();
tr.send(msg);
public class SMTPAuthenticator extends Authenticator
public PasswordAuthentication getPasswordAuthentication()
String username = SMTP_AUTH_USER;
String password = SMTP_AUTH_PWD;
return new PasswordAuthentication(username, password);
the error i am receiving is:
java.lang.NoClassDefFoundError: javax/mail/Authenticator
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
java.lang.Class.getConstructor0(Unknown Source)
java.lang.Class.newInstance0(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:143)
org.apache.struts.action.RequestProcessor.processActionCreate(RequestProcessor.java:292)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:230)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
If anyone has any ideas it will be much appreciated
Thanks in Advance
Andy -
Assistance needed with new monitor and printing from LR3
I just purchased a new IPS monitor. I have calibrated it using the HP Display assistant that came with it. It is an HP ZR 22w. I saved my calibration as a preset - however - this is not appearing as a profile when I try to select it in the print module. the checkbox for "include display profiles" is ticked. If I allow the printer to manage - the pictures are much warmer than on the IPS display. My printer is a canon mg6120 and I am running windows 7. I would appreciate any assistance that anyone can provide. Thank you
I think the "HP Display assistant" is a software tool, is that right?
Ideally with Lightroom, you should use a hardware calibration/profiling tool (Spyder, Eye One, Color Munki etc). In particular, you need a monitor profile that contains colour space information. I had a look through the HP Display Assistant user manual, and it appears the software does calibration but it probably doesn't put colour space info in the profile. It'll be better than nothing, but a hardware tool is better.
However:
I saved my calibration as a preset - however - this is not appearing as a profile when I try to select it in the print module. the checkbox for "include display profiles" is ticked. If I allow the printer to manage - the pictures are much warmer than on the IPS display. My printer is a canon mg6120 and I am running windows 7
This is not what you want to do! The profile that the HP Display Assistant creates is for the monitor, and only for the monitor. It gets the right white point and tone curve for the monitor. What you need in the profile drop-down in LR print module is a printer profile, not a monitor profile (except on very special circumstances).
I'm not familiar with the MG6120, but when I googled "profiles for canon mg6120" I got a lot of hits, so I assume profiles are available. It's quite likely that some came with the printer driver, and were installed with the printer software. When you select "profile" in LR print module (you may well have to go to "Other..." to see them all) then there should be profiles for the printer - possible lots of them - one or more for each paper type. If they're not there, see the Canon documentation (or google it) to find out how to load them.
If you can't find any profiles for the printer, then try using sRGB (or probably it's "sRGB IEC..."). Without colour management, your printer will probably expect sRGB images, so this should be roughly right, but a specific profile for the printer is better. This is one of those very special circumstances when something other than a printer profile (and sRGB isn't a printer profile) may be better than nothing. -
Hi,
Im doing a project for my module at uni. Not being a programmer I find it very hard to design application as Im required to. Anyway I have to design booking application for bikeshop.
User selects bike from 3 types: MTB,Kids and racing. each bike has its price so cost of booking must be calculated.There are extra options like helmet which may rented as well. Some customer info must be collected (name,address etc).
Bookings has to be written into file. Report of past booking must be available-simple printouts.
No databases as use of arrays is required.
Im stuck and trying to figure it out how to read from array which contains bike types and prices and extra features. Then combine several bookings for on customes on a form/interface.
Any ideas how to start it? I mean at least on design level.
Thanks in advance for any helpHi
I managed to produced some code to extend my app but when I run it I get:
Exception in thread "main" java.lang.NullPointerException
at ReservationSystem.main(ReservationSystem.java:22)
Im really stuck
Will somebody give me any idea?
Below is the code...
Thanks
whale
mport java.util.ArrayList;
import javax.swing.JOptionPane;
public class ReservationSystem {
static ArrayList<Booking> Bookings;
public static void main(String[] args) {
int BikeType = 0;
do {
BikeType = Integer.parseInt(JOptionPane.showInputDialog("0 - Mountain bike, 1 - Racing Bike, 2 - Childrens Bike, 3 - Finish?"));
String Surname = JOptionPane.showInputDialog("Surname?");
String Date = JOptionPane.showInputDialog("Date?");
int Number_of_days = Integer.parseInt(JOptionPane.showInputDialog("Number of days?"));
switch (BikeType) {
case 0:
String Sex = JOptionPane.showInputDialog("Sex (M/F)?");
String Frame_size = JOptionPane.showInputDialog("Frame size (S/M/L)?");
boolean Helmet = JOptionPane.showConfirmDialog(null, "Is a helmet required?", "Helmet", JOptionPane.YES_NO_OPTION) == 0;
Bicycle Bike = new MountainBike(Sex, Frame_size, Helmet);
Bookings.add(new Booking(Surname, Date, Number_of_days, Bike));
case 1:
case 2:
default:
} while (BikeType != 3);
int Length = Bookings.size();
int i;
for (i = 0; i < Length; i++) {
Bookings.get(i).print_booking();
}Booking class
public class Booking {
//Date start_date;
int Number_of_days;
Bicycle Bike;
String Surname;
String Date;
Booking(String Surname, String Date, int Number_of_days, Bicycle Bike) {
this.Surname = Surname;
this.Number_of_days = Number_of_days;
this.Bike = Bike;
this.Date = Date;
public void print_booking() {
System.out.print(this.Surname + ": " + this.Date + "/" + " for " + this.Number_of_days);
this.Bike.print_bike();
}}class Bicycle
public class Bicycle {
int Price;
boolean Helmet;
public void print_bike() {
class MountainBike extends Bicycle {
String Frame_size;
String Sex;
public MountainBike(String Sex, String Frame_size, boolean Helmet) {
this.Sex = Sex;
this.Frame_size = Frame_size;
this.Helmet = Helmet;
this.Price = 20;
if (Helmet) {
this.Price += 5;
public void print_bike() {
System.out.println("Mountain bike (" + this.Sex + ", " + this.Frame_size + ") "
+ (this.Helmet ? " with helmet" : "") + " price " + this.Price);
class RacingBike extends Bicycle {
boolean Panniers;
String Frame_size;
String Sex;
public RacingBike(String Sex, String Frame_size, boolean Panniers) {
this.Sex = Sex;
this.Frame_size = Frame_size;
this.Panniers = Panniers;
this.Price = 25;
if (Panniers) {
this.Price += 10;
this.Helmet = true;
public void print_bike() {
System.out.println("Racing bike (" + this.Sex + ", " + this.Frame_size + ") "
+ (this.Panniers ? " with panniers" : "") + " price " + this.Price);
class ChildrensBike extends Bicycle {
int Age;
public ChildrensBike(int Age) {
this.Age = Age;
this.Helmet = true;
this.Price = 15;
public void print_bike() {
System.out.println("Mountain bike (" + this.Age + ") "
+ (this.Helmet ? " with helmet" : "") + " price " + this.Price);
} -
Simple Java probablitity program?
Could anyone type up a simple probability program?
For example...
a has a chance of being picked .44
b has .22
c has .30
d has .04
All added equals 1.00
So, how would I print a string of 50 chars, a through d, with those probabilities/chances?javalavalamp wrote:
Hell, the last time I ever posted was Sept...
Profile: http://forums.sun.com/profile.jspa?userID=1052864
I'm not talking about here, I'm talking about posting the same question in multiple forums. Again, this will frustrate anyone who tries to help you only to find out later that the same answer was given hours ago in a cross-posted thread.
So again, what other fora did you post this in?
Maybe you are looking for
-
[3/3/2010 Update] There's a issue of using 4Gb sticks on T410 currently that results in video output artifacts and aero interface problems when using Lenovo supplied drivers v8.16.11.8825. I think I can call it confirmed (Three people including me fa
-
Aperture 3 and Adobe Photoshop Elements 10 problems.
I have installed Adobe Photoshop Elements 10, which I have setup as plugin for Aperture 3. In Aperture preferences the photos are exported as 8 bit TIFF 300 DPI, no profile and automatically stack new versions selected in general. I right click on se
-
I summitted a job on solaris 9
please, can any body help me out with this issue, I summitted a job but after some time the job change to a status of either stop or suspended. Please, help out
-
When i use language for non-unicode [Russian] and i insert another language
when i use language for non-Unicode [Russian] and i insert another language. it transform to Russian. i insert Thai language into MS access it transform to Russian type.i try to change anything,CharSet, sun.jnu.encoding. but it doesn't have any effec
-
Mail and safari won't work after installing lion.
After upgrading my computer to Snow Leopard then to Lion I am unable to open Safari and Mail. The computer says the versions I have are not compatible with Lion. I have checked to see if there are any available updates by selecting the apple at the