Set Pasword in any folder through java (HELP NEEDED)
hi i want know it is possibel in java i m set password in any folder of my windows if it is so reply me soon .
i m waiting for reply
In java only - no.
If there is a command line tool that does it then you can use Runtime.exec() with an OS specific command. Presumably you are talking about windows so you might look in the appropriate resource kit. That is probably the most likely location for a command. But it could be somewhere else too.
If you can't find a command then you would have to use JNI.
Similar Messages
-
How to create a folder through java
Hi All,
Can any one give the solution of my prob.
I want to create a folder in windows m/c through java programe .Is it possible.
If yes then kindly suggest me how...?
Thanks In advance
VikasString newFolderPath = "C:\\";
String newFolderName = "MyFolder";
String spoonFeeding = newFolderPath + newFolderName;
File f = new File(spoonFeeding);
f.mkDir(); -
How to set values to unniverse prompts through java
Hi
I am using JAVA -BOSDK to access reports from infoview. I have a problem when any universe level prompt is present in the report. I am able to retrieve it through java when i say documentInstance.getPrompts() and when i set values to this prompt by Prompt.enterValues(String[] parameters) and then either save the report or saveAs another report , my new values dont get applied to the prompt. Only previous values get applied to the prompt. I checked doing prompt.getPreviousValues and prompt.getCurrentValues but when i save the doc then new values are not set.
here is a part of code iam using: the filterlist contains the ConditionFilterDataItems objects which contain the operands,operator and queryObjectName .I have added multiple prompt.getPrevious and current values for debug purpose.
private static void applyValuesToUniversePrompt( final DocumentInstance doc, final List filterList )
final DataProviders dps = doc.getDataProviders() ;
final DataProvider dataProvider = dps.getItem( 0 ) ;
final Query query = dataProvider.getQuery() ;
Prompts newPrompts = doc.getPrompts();
Prompt newprompt = newPrompts.getItem( 0 );
newprompt.getPreviousValues();
newprompt.getCurrentValues();
final ConditionContainer conditioncont = (OMConditionContainer) query.getCondition() ;
ConditionFilterDataItem conditionFilterDataItem = null ;
final Map promptMap = generateInstanceMap( doc ) ;
//Prompt [] promptArr ;
for( int i = 0 ; i < filterList.size() ; i++ )
conditionFilterDataItem = (ConditionFilterDataItem) filterList.get( i ) ;
final String [] operands = conditionFilterDataItem.getFilterOperand() ;
PromptsImpl univPrompts = (PromptsImpl)doc.getPrompts();
Prompt [] promptArr = new Prompt[univPrompts.getCount()];
for(int k= 0;k< univPrompts.getCount();k++)
promptArr[k] =(Prompt) univPrompts.getItem( k );
if(univPrompts.getCount()==0)
promptArr=null;
if(promptArr!=null)
for( int j = 0 ; j < promptArr.length ; j++ )
final Prompt prompt = promptArr [j] ;
final String promptName = prompt.getName() ;
final Prompt currentPrompt = (Prompt) promptMap.get( promptName ) ;
if( operands [j] != null )
currentPrompt.getPreviousValues();
currentPrompt.getCurrentValues();
currentPrompt.removeValues( currentPrompt.getPreviousValues() );
currentPrompt.enterValues( convertStringToArray( operands [j] ) ) ;
currentPrompt.getPreviousValues();
currentPrompt.getCurrentValues();
doc.setPrompts();
newPrompts = doc.getPrompts();
newprompt = newPrompts.getItem( 0 );
newprompt.getPreviousValues();
newprompt.getCurrentValues();
//doc.setPrompts() ;
doc.refresh();
doc.save();
newPrompts = doc.getPrompts();
newprompt = newPrompts.getItem( 0 );
newprompt.getPreviousValues();
newprompt.getCurrentValues();
// dataProvider.runQuery() ;
doc.refresh();
doc.saveAs( "universePrompt2",7148,null,null ) ;
doc.closeDocument() ;
private static Map generateInstanceMap( final DocumentInstance document )
final Map promptMap = new HashMap() ;
final Prompts prompts = document.getPrompts() ;
int count ;
if( prompts != null )
count = prompts.getCount() ;
for( int i = 0 ; i < count ; i++ )
final Prompt prompt = prompts.getItem( i ) ;
promptMap.put( prompt.getName(), prompt ) ;
return promptMap ;Hi Shruti,
Can U kindly refer this [thread|BusinessObjects Enterprise Java Software Development Kit (SDK) ??; and reply back.
Would appreciate your efforts !!! -
How to set the Date in excel through Java?
now i am using
cell.setCellValue(date);
date is in format of "dd/MM/yyyy"
But when it set on excel , it sets as number.
I need the date as in same format as what i given.
Assist me.Consult the docs of the API you're using. We can't say much about it because you didn't even mention the API used and it is also not recognizeable as part of any standard Sun Java API's. It might help to consult their own forum/mailinglist -if any- as well.
-
Setting up the Network Folder through the EWS.
Hi,
I'm having trouble setting up the network folder feature in the EWS. I created a destination folder on my desktop in another folder called (desktopfiles). In the EWS - in the display name field - I called the folder (HP Files).
In the network path field I put (\\myusername\desktopfiles) . I test and get Network connection failed.
note: Under network user name I put in my wireless network and password info.
Am I filling these forms out correctly?FYI. I keep getting network connection failed after every test.
-
The web site www.everbank.com has been updated. It has a 3 panel display in the top half that rotates through the three offerings and you can pause it if you wish. It does not display on Firefox. I am using 19.0.2 and it says it is up to date. Everbank has looked into and it displays correctly for them and it displays correctly for me on IE9. I inadvertantly have the beta version of Mozilla (19.2) on my desktop and the web page displays correctly there. I have cleared the cache, looked at firewall settings (Windows 7) and have added Mozilla. Nothing has helped.
It works for me as long as JavaScript is enabled. If it's not enabled, I get a jumble of text as the 3 slides are superimposed on one another. Do you just get a blank area?
Since you cleared your cache, out of data pages, style sheet, and scripts shouldn't be a factor. Could you also clear your cookies for the site? While viewing a page on the site:
* right-click and choose View Page Info > Security > "View Cookies"
* Alt+t (open the classic Tools menu) > Page Info > Security > "View Cookies"
Remove the everbank cookies individually there, then try reloading the page. Does that make any difference?
When you compared with the beta version of Firefox, were you running with the identical settings folder, i.e., same bookmarks, settings, and add-ons? I'm guessing there might be a difference.
To check for potential add-on conflicts, try disabling ALL nonessential or unrecognized extensions here, then restart Firefox:
orange Firefox button (or Tools menu) > Add-ons > Extensions category
Any luck? -
Using command prompt through java, help please!
Hi,
What I am trying to do is find all the processes running onthe computer using java. Normally, I would do this (without java) by opening a command prompt window, typing in tasklist and see all the running processes. I have tried to to do the same thing using java, but so far have been unsucsessful. Here is my code:
import java.io.*;
public class Main {
static DataOutputStream output;
static DataInputStream input;
static String app="cmd.exe";
static String command="tasklist";
static String message="";
public static void main(String args[])throws Exception{
Process process = Runtime.getRuntime().exec(app);
output=new DataOutputStream(process.getOutputStream());
input=new DataInputStream(process.getInputStream());
output.write(command.getBytes());
byte[] b=new byte[input.available()];
input.readFully(b);
message=new String(b);
System.out.println("Message: "+message);
System.out.println(!message.equals(""));
System.out.println(message!=null);
System.out.println("Finished Program");
}And this program prints the output (with no exceptions):
Message:
false
true
Finished Program
I appreciate any help in fixing my program...DevRocks_Java wrote:
static String app="cmd.exe";
static String command="tasklist";
Process process = Runtime.getRuntime().exec(app);
output=new DataOutputStream(process.getOutputStream());
input=new DataInputStream(process.getInputStream());What do you expect it to do? You are only telling it to open a console window, nothing more.
if you can type tasklist at the run option, then you should be able to just substitute command in for app in your exec. -
Unable to create a folder through java code on weblogic server 10GR3
Hi,
I have java code which creates a folder and writes an XML file in to it.
File saveDirectory = new File(storePath);
if(!saveDirectory.exists()){
System.out.println("directory doesnt exists");
boolean isDirectoryCreated = saveDirectory.mkdir();
System.out.println("directory doesnt exist creating status :"+isDirectoryCreated);
This code works fine on my local weblogic server.Whereas the one installed on Unix box is not.
saveDirectory.mkdir() is unable to create a directory at the given path.
I feel there is some permission problems.
Please let me know what can be done.
Thanks,I have my Linux/Unix Admin either add me to a group that can do this or create one that can and add me to it.
If you command prompt can you manually do it now?
Best Regards
mseberg -
New to java,,,help needed urgently
I am geeting a compile error..."cannot resolve symbol" in my main class. The program is supposed to prompt the user for five sets of data, and calculate the tax and total of the entered products and print it back to the screen, it is also supposed to calculate the cheapest and most expensive item and print them back. can someone pls shed some light on this error msg, as I cant seem to get my head around it.
import java .io.*;
import java.util.StringTokenizer;
import java.text.NumberFormat;
import java.util.Locale;
//set up a class to call on the constructors from the catalogueitem class
public class Myassg4
private static final int MAX = 2;//sets the length to 2
private static CatalogueItem[] prodlist ;//sets array for product list
NumberFormat cash = NumberFormat.getCurrencyInstance(new Locale("en","AU"));
private static void main(String[] args) throws IOException
{//declare the variables and initialize
double preTotal = 0.00;
String inString;
double maximum, lowest;
double sum = 0.00;
BufferedReader stdin = new BufferedReader (new
InputStreamReader(System.in));
prodlist = new CatalogueItem[];//sets the length (THIS IS WHERE THE PROBLEM OCCURS!!!!)
System.out.println("Enter 5 sets of data");
//loop through the array and read the data in
for(int i = 0;i <prodlist.length;i++)
inString = stdin.readLine();
//create a String Tokenizer to read the data separately
StringTokenizer tok = new StringTokenizer(inString, ":");
prodlist[i] = new CatalogueItem(tok.nextToken(), tok.nextToken(),
Double.parseDouble(tok.nextToken()));
}//end of loop
//create a header and print the data back to the screen
System.out.println();
System.out.println("LISTING OF ALL GOODS");
System.out.println();
System.out.println("Cat\tDescription\tExTax\tTax\tIncTax");
System.out.println("___\t___________\t_____\t___\t______");
System.out.println();
for(int j = 0;j <prodlist.length;j++){
System.out.println(prodlist[j].getCatno()+"\t"+prodlist[j].getDesc()+
"\t"+prodlist[j].getPrice()+"\t"+prodlist[j].getTax()
+"\t"+prodlist[j].getIncTax());
I have errors every where the prodlist is used, I know I am not initializing it correctly but dont know what the alternatives are.daniel here is the entire code if you do get a chance can you pls have a look at it for me thanks.
import java .io.*;
import java.util.StringTokenizer;
import java.text.NumberFormat;
import java.util.Locale;
//set up a class to call on the constructors from the catalogueitem class
public class Myassg4
private static final int MAX = 2; //sets the length to 2
private static CatalogueItem[] prodlist; //sets array for product list
NumberFormat cash = NumberFormat.getCurrencyInstance(new Locale("en","AU"));
private static void main(String[] args) throws IOException
{//declare the variables and initialize
double preTotal = 0.00;
String inString;
double maximum, lowest;
double sum = 0.00;
BufferedReader stdin = new BufferedReader (new
InputStreamReader(System.in));
prodlist = new CatalogueItem[5];//sets the length
System.out.println("Enter 5 sets of data");
//loop through the array and read the data in
for(int i = 0;i <prodlist.length;i++)
inString = stdin.readLine();
//create a String Tokenizer to read the data separately
StringTokenizer tok = new StringTokenizer(inString, ":");
prodlist[i] = new CatalogueItem(tok.nextToken(), tok.nextToken(),
Double.parseDouble(tok.nextToken()));
}//end of loop
//create a header and print the data back to the screen
System.out.println();
System.out.println("LISTING OF ALL GOODS");
System.out.println();
System.out.println("Cat\tDescription\tExTax\tTax\tIncTax");
System.out.println("___\t___________\t_____\t___\t______");
System.out.println();
for(int j = 0;j <prodlist.length;j++){
System.out.println(prodlist[j].getCatno()+"\t"+prodlist[j].getDesc()+
"\t"+prodlist[j].getPrice()+"\t"+prodlist[j].getTax()
+"\t"+prodlist[j].getIncTax());
//use this data and call the cheapest method to print
//the cheapest goods in the catalogue
System.out.println();
System.out.println("CHEAPEST GOODS IN THE CATALOGUE");
System.out.println();
lowest = cheapest(prodlist, MAX);
System.out.println("Cat\tDescription\tExTax\tTax\tIncTax");
System.out.println("___\t___________\t_____\t___\t______");
System.out.println();
for(int k = 0;k <prodlist.length;k++){
if(prodlist[k].getTaxInc == lowest)
System.out.println(prodlist[k].Catno()+"\t"+prodlist[k].getDesc()+
"\t"+prodlist[k].getPrice()+"\t"+prodlist[k].getTax()
+"\t"+prodlist[k].getIncTax());
//use the listing of all goods and call the most expensive method
//to calculate and display back on screen
System.out.println();//create two lines of space in between
System.out.println();
System.out.println("MOST EXPENSIVE GOODS IN THE CATALOGUE");
System.out.println();
maximun = expensive(prodlist, MAX);
System.out.println("Cat\tDescription\tExTax\tTax\tIncTax");
System.out.println("___\t___________\t_____\t___\t______");
System.out.println();
for(int l = 0;l < prodlist.length;l++){
if(prodlist[l].getTaxInc == maximum)
System.out.println(prodlist[l].Catno()+"\t"+prodlist[l].getDesc()+
"\t"+prodlist[l].getPrice()+"\t"+prodlist[l].getTax()
+"\t"+prodlist[l].getIncTax());
//print the pretax worth of goods by calling the method and display
System.out.println();//create a two lines of space in between
System.out.println();
System.out.println("TOTAL OF PRE-TAX WORTH OF CATALOGUE ITEMS: "+preTaxWorth
(prodlist));
//print the avg tax payable per item
System.out.println();
System.out.println("AVERAGE AMOUNT OF TAX PAYABLE PER ITEM:"+avgTax
(prodlist));
//declare the other methods within the scope of the main class
public static double cheapest(CatalogueItem[] prodlist, int size)
double lowest = prodlist[0].getIncTac();
for(int i = 0; i < size;i++)
if(prodlist.getIncTax() < lowest)
lowest = prodlist[i].getIncTax();
return lowest;
public static double expensive(CatalogueItem[] prodlist, int size)
double maximum = prodlist[0].getTaxInc();
for(int i = 0; i < size; i++)
if(prodlist[i].getIncTax() > maximum)
maximum = prodlist[i].getIncTax();
return maximum;
public static double preTaxWorth(CatalogueItem[] prodlist)
{//add all the getPrice's in together
double preTax = 0; //prodlist[0].getPrice();
for(int i =0; i <prodlist.length; i++)
preTax += prodlist[i].getPrice();
return preTax;
public static double avgTax(CatalogueItem[] prodlist)
{//run through the array and add all the getTax amounts up.
double sum = 0;
for(int i = 0; i < prodlist.length; i++)
sum = sum + prodlist[i].getTax();
//to get the avg we divide the sum by the MAX number of entries
double Total = sum / MAX;
return Total;
}//end of main class
//CatalogueItem class
//catalogue item class
//ensure that the accesors and mutators
//are visible and cannot be overridden
class CatalogueItem
//declare the data types
private String catno;
private String desc;
private double price;
//declare the taxation rate constant
//but make it visible
public CatalogueItem(){
catno = " ";
desc = " ";
double price;
//declare the full constructor
CatalogueItem (String inCatno, String inDesc, double Price)
inCatno = catno;
inDesc = desc;
Price = price;
//name accessor---not overidable
public final String getCatno()
return catno;
//name product description accessor--not overidable
public final String getDesc()
return desc;
//name the extax method
public double getPrice()
return price;
//tax utility method
public double Tax()
double Tax;
Tax = 00.15 * getPrice();
return Tax;
//Including Tax method
public double IncTax()
double IncTax;
IncTax = Tax() + getPrice();
return IncTax; -
Calling perl script from java ---help needed
I haven't been doing a lot with java lately and i'm building an app with netbeans and having some difficulty with my button calling an outside perl script I'm pasting the code and error below...any help would be greatly appreciated. It's running on fedora 9 pretty much default install...
thanks.
code:
Runtime r = Runtime.getRuntime();
Process p = null;
String s = null;
String cmd123[] = { "perl /home/deaddev/test1.pl" };
try {
p = r.exec(cmd123);
catch {
foo bar/etc/etc
error:
Oct 12, 2008 4:09:37 PM photomainmgr readToPerlActionPerformed
SEVERE: null
java.io.IOException: Cannot run program "perl /home/deaddev/test1.pl": java.io.IOException: error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:474)
at java.lang.Runtime.exec(Runtime.java:610)
at java.lang.Runtime.exec(Runtime.java:483)
at photomainmgr.readToPerlActionPerformed(photomainmgr.java:117)
at photomainmgr.access$000(photomainmgr.java:21)
at photomainmgr$1.actionPerformed(photomainmgr.java:54)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:253)
at java.awt.Component.processMouseEvent(Component.java:6101)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3276)
at java.awt.Component.processEvent(Component.java:5866)
at java.awt.Container.processEvent(Container.java:2105)
at java.awt.Component.dispatchEventImpl(Component.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2163)
at java.awt.Component.dispatchEvent(Component.java:4288)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4461)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4125)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4055)
at java.awt.Container.dispatchEventImpl(Container.java:2149)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4288)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:604)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.<init>(UNIXProcess.java:164)
at java.lang.ProcessImpl.start(ProcessImpl.java:81)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:467)
... 30 more
error executing perl /home/deaddev/test1.pljschell wrote:
sabre150 wrote:
As and alternative you can useString cmd123 = "perl /home/deaddev/test1.pl";Using the single string approach YOU have to do any quoting so with this line no quoting takes place and the script /home/deaddev/test1.pl will be executed.Although that should be true apparently it isn't. I have just run
Process p = Runtime.getRuntime().exec("perl /home/sabre/work/dev/perl/xxx.pl");
new Thread(new SyncPipe(p.getErrorStream(), System.err)).start();
new SyncPipe(p.getInputStream(), System.out).run();
int returnCode = p.waitFor();
System.out.println("Return code = " + returnCode);which correctly executes the perl script xxx.pl.
P.S. SyncPipe is a Runnable that copies an InputStream to an OutputStream.
Edited by: sabre150 on Oct 14, 2008 9:19 AM
Interesting! Even though Runtime.exec() works with a single String, ProcessBuilder fails with this approach! You have to split the argument string. This certainly looks like a bug! Some while ago I looked at the source for Runtime.exec() to look at the differences between Runtime.exec() and ProcessBuilder and found that behind the scenes Runtime.exec() uses ProcessBuilder.
More research is required. -
Psuedocode to java. help needed if poss
i need to convert the following into java, but i am not sure how to output it..
Roll a 12 sided die to choose a number between 1...12
while the user has not made an incorrect guess
ask the user if the next number will be higher or lower
choose random number
if users guess is correct
increment count of correct guesses
update the stored current number
end if
end while
tell the user how many correct guesses there are
any help would be greatful, i am a beginning so go easy!!!
thanks alot
steviehey, sorry if i've caused a 'cross post', i am not too sure what it is but i hope i haven't done anything wrong! so far i am just trying to put a basic program together before building on it..
import java.util.scanner;
public class dice
public static void main (String [] args)
Scanner in = new Scanner(System.in);
Random rnd = new Random();
System.out.print("input a number between one and twelve") int r =in.nextInt;
int r = rnd.nextInt(12) + 1;
System.out.println(r);
i know this has errors, but i was just hoping for a hint/clue for the basic program before researching more to build on it.. hope this code will help. reply when you can, thank you very much
stevie -
Java help needed-Inventory System
I urgently need help in finishing my java inventory project for school. Can anyone help me usin files and streams to get the program to save data and help me get the menu to work pls THANKS> Heres the source code below:
// TextForm.java
// A simple label/field form panel
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class TextForm extends JPanel {
private JTextField[] fields;
// Create a form with the specified labels, tooltips, and sizes.
public TextForm(String[] labels,
int[] widths, String[] tips) {
super(new BorderLayout());
JPanel labelPanel = new JPanel(new GridLayout(labels.length, 1));
JPanel fieldPanel = new JPanel(new GridLayout(labels.length, 1));
add(labelPanel, BorderLayout.WEST);
add(fieldPanel, BorderLayout.CENTER);
fields = new JTextField[labels.length];
for (int i=0; i < labels.length; i+=1) {
fields[i] = new JTextField();
if (i < tips.length) fields.setToolTipText(tips[i]);
if (i < widths.length) fields[i].setColumns(widths[i]);
JLabel lab = new JLabel(labels[i], JLabel.RIGHT);
lab.setLabelFor(fields[i]);
labelPanel.add(lab);
JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
p.add(fields[i]);
fieldPanel.add(p);
JScrollBar JScrollBar = new JScrollBar();
JScrollBar vbar = new JScrollBar(JScrollBar.VERTICAL, 30, 40, 0, 300);
add(vbar, BorderLayout.EAST);
public String getText(int i) {
return( fields[i].getText() );
public static void main(String[] args) {
String[] labels = { "115ml Medicine", "236.60ml Water-clear", "236.60 Water-Amber", "250ml Irish Moss",
"250ml Sauce", "355ml Water", "380ml Juice", "473ml Vinegar", "500ml Water", "500 ml Blue Water", "600ml Water",
"750ml Syrup/honey", "900ml Disinfectant", "1000ml Syrup", "1500ml Water", "Total # caps:" };
int[] widths = { 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 ,12 };
String[] descs = { "", "Enter Quantity" };
final TextForm form = new TextForm(labels, widths, descs);
JButton submit = new JButton("Save Inventory");
JButton cancel = new JButton( "Cancel");
submit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showConfirmDialog(null,"Are you sure you want to save this record?");
JOptionPane.showMessageDialog(null, " Inventory status updated");
JOptionPane.showConfirmDialog(null, "Do you want to exit?");
JFrame f = new JFrame("Sweet Inventory System");
f.getContentPane().add(form, BorderLayout.NORTH);
JPanel p = new JPanel();
p.add(submit);
f.getContentPane().add(p, BorderLayout.CENTER);
f.pack();
f.setVisible(true);
Its error free except i cant see the menubar or get it to save items usin files and streams.
HELP PLEASETELL ME THE CODE I CAN USE TO MAKE IT SAVE ITEMS LIKE
IN A TEXT FILE AND HOW CAN I ATTACH IT TO THE SAVE
BUTTON USIN A LISTENER
THANKS
PLS POST HEREPosts like this make me ignore you forever. -
New to Java: Help Needed
Hi,
I am writing a utility to monitor all the objects created by my application. I want to be able to get not only values of class variables(for which the reflection package seems pretty useful), but also instance variables.
For example.
public class myClass {
//Constructor
public myClass(int i) {
// another class instantiates this one
myClass mc = new myClass(10);
myClass mc1 = new myClass(20);
I need to keep track of the the handles mc and mc1 and the
other initializations they do based on the value passed at runtime.
Is there a way to to this. Or even better, is there someplace in Java which stores all the objects instantiated and their handles?
Any suggestions would be greatly appreciated.
Thnx
cvsanHow do I access private and proteced variables. By default only the public variables are accessible via the reflect class as in the example below.
Class c = rc.getClass();
String s = c.getName();
System.out.println(s);
try { abcField = c.getField("abc");
where abc is a public instance variable. If abc is a private instance variable, the above example fails.
Is there any way to override the data hiding feature of Java?
Thanks
cvsan -
*Basic* Java help needed...
I feel like a complete novice for posting this kinda stuff, but i figured somebody would take 5 minutes and help me out. My final in my programming class depends on 2 programs, one of which is giving me some actual trouble.
What I have to do is create a java applet that allows a user to input their weight, select a planet, and then have their weight converted to what their weight would be on the selected planet. However, if the ouput is higher than 60 pounds, I need a picture of the michelin man to appear and the theme from star wars to play. If it is below 60, A multicolored asterisk should be displayed with applause.
I will post what code I have already made. Please note: ITS VERY VERY BASIC. I may have overcomplicated some things, and there is always more than one way to do something (in my experience). Also, I kinda just converted a temperature conversion applet, so there may be some extra stuff I don't need.
Please help.
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class tempsapp2 extends Applet implements ActionListener
Label prompt1;
TextField input1;
Label prompt2;
TextField input2;
int number1, number2;
int mercury, venus, earth, mars, jupiter, saturn, neptune, uranus, pluto, result;
public void init()
prompt1 = new Label ("Enter your weight:");
add (prompt1);
input1 = new TextField (10);
add (input1);
prompt2 = new Label ("Enter the Number of the Planet you would like to have your weight converted to:");
add (prompt2);
input2 = new TextField (10);
add (input2);
input2.addActionListener(this);
add (input2);
public void paint (Graphics g)
number1 = Integer.parseInt(input1.getText());
number2 = Integer.parseInt(input2.getText());
mercury = (number1*3780)/1000;
venus = (number1*9070)/1000;
earth = (number1*10)/1000;
mars = (number1*3770)/1000;
saturn = (number1*9160)/1000;
uranus = (number1*8890)/1000;
neptune = (number1*1125)/1000;
jupiter = (number1*2364)/1000;
pluto = (number1*670)/1000;
if(number2==1)
g.drawString("Your weight on Mercury would be "+mercury+" lbs",100,150);
else if(number2==2)
g.drawString("Your weight on Venus would be "+venus+" lbs",100,150);
else if(number2==3)
g.drawString("Your weight on Earth would be "+earth+" lbs",100,150);
else if(number2==4)
g.drawString("Your weight on Mars would be "+mars+" lbs",100,150);
else if(number2==5)
g.drawString("Your weight on Jupiter would be "+jupiter+" lbs",100,150);
else if(number2==6)
g.drawString("Your weight on Saturn would be "+saturn+" lbs",100,150);
else if(number2==7)
g.drawString("Your weight on Uranus would be "+uranus+" lbs",100,150);
else if(number2==8)
g.drawString("Your weight on Neptune would be "+neptune+" lbs",100,150);
else if(number2==9)
g.drawString("Your weight on Pluto would be "+pluto+" lbs",100,150);
public void actionPerformed(ActionEvent evt)
number1 = Integer.parseInt(input1.getText());
number2 = Integer.parseInt(input2.getText());
repaint();
}I am guessing that you are wondering where to go from here. If so http://java.sun.com/products/plugin/1.5.0/demos/applets/Animator/Animator.java may prove helpful.
Also I would recommend using arrays of planet names and weight multipliers. It could make your code a lot less cumbersome. -
Java help needed(PLEASE)
I have a Question for all you gifted people:
I am designing a sort of quiz which takes questions and three possible answers from a database(which also holds the real answer).It prints these on the dos screen and I then have a System.in statement which allows the user to enter his or her answer (eg A,B,C or 1,2,3). I need a way of adding up the score at the end!!I was thinking of storing there answers in an array and compairing there answer to my correct answer in the database and if it is the same add 1 and if it not the same add 0???
How would i write the System.in answers into an array and add them up???
These are my thoughts on how to do this i would love to hear yours!! And also a help with writing the code for the above system of scoreing would be GREATLY appriciated!!
thanks everyone,
james.As mathuoa pointed out, since you already display the 3 possible answers to the user, get them into an array and display them on the screen. Then, as the user enters an answer, compare them with the three answers and if it is correct, update the score variable as such. If you want the history of answers that the user has given, then u will have to use a Vector/List/some such collection object to hold the user's answers.
java.util.Vector answers = new java.util.Vector();
answers.add(usersAnswer1);
answers.add(usersAnswer2);
Then, to get the entries,
for(Enumeration e = answers.elements(); e.hasMoreElements();)
System.out.println(e.nextElement());
//Do something with the answer.
This is one possible way of getting the answers from the user!
Maybe you are looking for
-
What are the impacts of IB control set to No at Master level
What are the impacts of IB control set to No at Master level, but the item is serialized at master and Org level. These are service items.
-
Is there a link between my 10g Application Server login and my 10g database session id? Will Oracle Enterprise Manager show which end user has which database session?
-
Photos Wont Open Even After Restart
Every time I open up Photos it says "Unexpected error occurred please quit and restart the application." I click the quit button which quits the program and when I reopen it, the same message comes back up. I have shut down my computer, restarted my
-
DVCPRO HD downconverting to SD & MP2
I've searched the forum and haven't found the exact answer to my problem. I have a music video in DVCPRO HD 50i. I want to make a DVD, a PAL SD version, and a smaller Quicktime version to play on computers. I've made the SD versions by putting the DV
-
NI PXI 6229 DAQ Card Digital Output High/Low Levels
Hi everyone, I can't seem to find in the NI PXI 6229 DAQ spec what the Digital Output high voltage and low voltage is when I set a digital signal high and low. What is the voltage when I set a Digital Output "HIGH" and what is the voltage when I set