Program compiles, but does not run
To: XCode Users <[email protected]>
From: Brigit Ananya <[email protected]>
Subject: Program compiles, but does not run
I am trying to port a Java application from the PC to the Mac. I am using XCode and the program compiles, but it does not run.
When I try to run the ...app, I get the message that the main class is not specified, etc.
When I try to run the ...jar, I do not get the message that the main class is not specified, but I do get the message that there is no Manifest section for bouncycastle, etc.
Here are the detailed messages I get in the Console when I try to run the program:
When I try to run the ...app, I get the following message:
1/9/09 7:21:17 AM [0x0-0x8c08c].com.AnanyaSystems.AnanyaCurves[2253] [LaunchRunner Error] No main class specified
1/9/09 7:21:17 AM [0x0-0x8c08c].com.AnanyaSystems.AnanyaCurves[2253] [JavaAppLauncher Error] CallStaticVoidMethod() threw an exception
1/9/09 7:21:17 AM [0x0-0x8c08c].com.AnanyaSystems.AnanyaCurves[2253] Exception in thread "main" java.lang.NullPointerException
1/9/09 7:21:17 AM [0x0-0x8c08c].com.AnanyaSystems.AnanyaCurves[2253] at apple.launcher.LaunchRunner.run(LaunchRunner.java:112)
1/9/09 7:21:17 AM [0x0-0x8c08c].com.AnanyaSystems.AnanyaCurves[2253] at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:50)
1/9/09 7:21:17 AM [0x0-0x8c08c].com.AnanyaSystems.AnanyaCurves[2253] at apple.launcher.JavaApplicationLauncher.launch(JavaApplicationLauncher.java:52)
When I try to run the ...jar, I do get the following message:
1/9/09 7:22:43 AM [0x0-0x8d08d].com.apple.JarLauncher[2262] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] Exception in thread "main"
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] java.lang.SecurityException: no manifiest section for signature file entry org/bouncycastle/asn1/DEREnumerated.class
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at sun.security.util.SignatureFileVerifier.verifySection(SignatureFileVerifier.java:377)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:231)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:176)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at java.util.jar.JarVerifier.processEntry(JarVerifier.java:233)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at java.util.jar.JarVerifier.update(JarVerifier.java:188)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at java.util.jar.JarFile.initializeVerifier(JarFile.java:325)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at java.util.jar.JarFile.getInputStream(JarFile.java:390)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at sun.misc.URLClassPath$JarLoader$1.getInputStream(URLClassPath.java:620)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at sun.misc.Resource.cachedInputStream(Resource.java:58)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at sun.misc.Resource.getByteBuffer(Resource.java:113)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at java.net.URLClassLoader.defineClass(URLClassLoader.java:249)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at java.security.AccessController.doPrivileged(Native Method)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
1/9/09 7:28:45 AM [0x0-0x8f08f].com.apple.JarLauncher[2277] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
I do specify the main class in both, the Manifest file and the Info.plist file, in the correct way, "package.MainClass". Is there another place where I need to specify it?
Why do I need org/bouncycastle/asn1/DEREnumerated.class, and how would I have to specify it in Manifest?
I also posted these questions at Mac Programming at forums.macrumors.com and at Xcode-users Mailing List at lists.apple.com/mailman/listinfo, but I did not get any answer.
Please help! Thanks!
There was something wrong with my Info.plist file.
So, here is my corrected Info.plist file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>AnanyaCurves</string>
<key>CFBundleGetInfoString</key>
<string></string>
<key>CFBundleIconFile</key>
<string>AnanyaCurves.icns</string>
<key>CFBundleIdentifier</key>
<string>com.AnanyaSystems.AnanyaCurves</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>AnanyaCurves</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.1</string>
<key>CFBundleSignature</key>
<string>ac</string>
<key>CFBundleVersion</key>
<string>0.1</string>
<key>Java</key>
<dict>
<key>JMVersion<key>
<string>1.4+</string>
<key>MainClass</key>
<string>AnanyaCurves</string>
<key>VMOptions</key>
<string>-Xmx512m</string>
<key>Properties</key>
<dict>
<key>apple.laf.useScreenMenuBar</key>
<string>true</string>
<key>apple.awt.showGrowBox</key>
<string>true</string>
</dict>
</dict>
</dict>
</plist>Ok, so now I can at least run the AnanyaCurves.jar file by double-clicking on it.
However, I still cannot run the AnanyaCurves.app file. When I double-click on it, I get the following message in the Console:
1/11/09 5:12:26 PM [0x0-0x67067].com.apple.JarLauncher[1128] at ananyacurves.AnanyaCurves.main(AnanyaCurves.java:1961)
1/11/09 5:13:11 PM [0x0-0x6a06a].com.AnanyaSystems.AnanyaCurves[1137] [JavaAppLauncher Error] CFBundleCopyResourceURL() failed loading MRJApp.properties file
1/11/09 5:13:11 PM [0x0-0x6a06a].com.AnanyaSystems.AnanyaCurves[1137] [LaunchRunner Error] No main class specified
1/11/09 5:13:11 PM [0x0-0x6a06a].com.AnanyaSystems.AnanyaCurves[1137] [JavaAppLauncher Error] CallStaticVoidMethod() threw an exception
1/11/09 5:13:11 PM [0x0-0x6a06a].com.AnanyaSystems.AnanyaCurves[1137] Exception in thread "main" java.lang.NullPointerException
1/11/09 5:13:11 PM [0x0-0x6a06a].com.AnanyaSystems.AnanyaCurves[1137] at apple.launcher.LaunchRunner.run(LaunchRunner.java:112)
1/11/09 5:13:11 PM [0x0-0x6a06a].com.AnanyaSystems.AnanyaCurves[1137] at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:50)
1/11/09 5:13:11 PM [0x0-0x6a06a].com.AnanyaSystems.AnanyaCurves[1137] at apple.launcher.JavaApplicationLauncher.main(JavaApplicationLauncher.java:61)Why is it looking for the MRJApp.properties file? Isn't this outdated? Shouldn't it look for the Info.plist file? I do not have a MRJApp.properties file.
Also, in the Run menu of my XCode project, Go, Run, and Debug are disabled, but perhaps this has to do with not being able to run the AnanyaCurves.app file.
Thanks for your time! I really appreciate any help you can give me!
Similar Messages
-
premiere elements 12, new installation, serial no. accepted, installation completed and new started, but does not run. I get following msg-box: "LoadLibrary failed with error 126: Das angegebene Modul wurde nicht gefunden." Installation in German Language on WIN7 professional 64bit, Samsung SSD. What can I do to run that program?
Jurgen Freund
Premiere Elements 12 on Window 7 64 bit. What video card/graphics card does your computer use - AMD Radeon?
I have found this YouTube video on the subject of Error 126 with details for resolving the problem.
How to fix the ERROR 126 when you open OpenGL programs - YouTube
The link was contributed in an old 2013 thread here by the ID danneomarre (see post 6 of the following thread)
LoadLibrary failed with error 126: cant find the required
Please let us know if that worked for you.
Thank you.
ATR
Add On...When all is OK and working, please update 12 to 12.1 Update using an opened project's Help Menu/Update. -
Applet compiles but does not appear...
the applet compiles but does not appear :(
all that appears is a blank box...hopefully someone can help
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class program2 extends Applet implements ActionListener
private Button btLeft, btRight, btUp, btDown, btBgYellow,
btBgRed, btBgBlue, btBgOrange, btTxtRed,btTxtYellow, btTxtBlue,
btTxtOrange, btFtHel, btFtCr, btFtTr, btFtSy;
private MessagePanel messagePanel;
private Panel p = new Panel();
public void init()
p.setLayout(new BorderLayout());
messagePanel = new MessagePanel("Java is Life");
messagePanel.setBackground(Color.white);
//directional buttons
Panel pButtons = new Panel();
pButtons.setLayout(new FlowLayout());
pButtons.add(btLeft = new Button());
pButtons.add(btRight = new Button());
pButtons.add(btUp = new Button());
pButtons.add(btDown = new Button());
//Background buttons
Panel BgButtons = new Panel();
BgButtons.setLayout(new FlowLayout());
BgButtons.add(btBgRed = new Button());
btBgRed.setBackground(Color.red);
BgButtons.add(btBgYellow = new Button());
btBgYellow.setBackground(Color.yellow);
BgButtons.add(btBgBlue = new Button());
btBgBlue.setBackground(Color.blue);
BgButtons.add(btBgOrange = new Button());
btBgOrange.setBackground(Color.orange);
//text color buttons
Panel txtButtons = new Panel();
txtButtons.setLayout(new GridLayout(4,1));
txtButtons.add(btTxtRed = new Button());
btTxtRed.setBackground(Color.red);
txtButtons.add(btTxtYellow = new Button());
btTxtYellow.setBackground(Color.yellow);
txtButtons.add(btTxtBlue = new Button());
btTxtBlue.setBackground(Color.blue);
txtButtons.add(btTxtOrange = new Button());
btTxtOrange.setBackground(Color.orange);
//font buttons
Panel ftButtons = new Panel();
ftButtons.setLayout(new GridLayout(4,1));
ftButtons.add(btFtHel = new Button());
ftButtons.add(btFtCr = new Button());
ftButtons.add(btFtTr = new Button());
ftButtons.add(btFtSy = new Button());
//layout
p.add(messagePanel, BorderLayout.CENTER);//set center 1st
p.add(pButtons, BorderLayout.SOUTH);
p.add(BgButtons, BorderLayout.NORTH);
p.add(txtButtons, BorderLayout.EAST);
p.add(ftButtons, BorderLayout.WEST);
//listeners
btLeft.addActionListener(this);
btRight.addActionListener(this);
btUp.addActionListener(this);
btDown.addActionListener(this);
btBgRed.addActionListener(this);
btBgYellow.addActionListener(this);
btBgBlue.addActionListener(this);
btBgOrange.addActionListener(this);
btTxtRed.addActionListener(this);
btTxtYellow.addActionListener(this);
btTxtBlue.addActionListener(this);
btTxtOrange.addActionListener(this);
btFtHel.addActionListener(this);
btFtCr.addActionListener(this);
btFtTr.addActionListener(this);
btFtSy.addActionListener(this);
//implement listener
public void actionPerformed(ActionEvent e)
if(e.getSource() == btLeft)
left();
else if(e.getSource() == btRight)
right();
else if(e.getSource() == btUp)
up();
else if(e.getSource() == btDown)
down();
else if(e.getSource() == btBgRed)
red();
else if(e.getSource() == btBgYellow)
yellow();
else if(e.getSource() == btBgBlue)
blue();
else if(e.getSource() == btBgOrange)
orange();
else if(e.getSource() == btTxtRed)
redText();
else if(e.getSource() == btTxtYellow)
yellowText();
else if(e.getSource() == btTxtBlue)
blueText();
else if(e.getSource() == btTxtOrange)
orangeText();
else if(e.getSource() == btFtHel)
helvetica();
else if(e.getSource() == btFtCr)
courier();
else if(e.getSource() == btFtTr)
times();
else if(e.getSource() == btFtSy)
symbol();
//directional methods :0)
private void left()
int x = messagePanel.getXCoordinate();
if(x > 10)
messagePanel.setXCoordinate(x - 10);
messagePanel.repaint();
private void right()
int x = messagePanel.getXCoordinate();
if(x < (getSize().width - 5))
messagePanel.setXCoordinate(x + 5);
messagePanel.repaint();
private void up()
int y = messagePanel.getYCoordinate();
if(y < (getSize().height - 10))
messagePanel.setYCoordinate(y - 10);
messagePanel.repaint();
private void down()
int y = messagePanel.getYCoordinate();
if(y < (getSize().height + 10))
messagePanel.setYCoordinate(y + 10);
messagePanel.repaint();
//background methods :)
private void red()
messagePanel.setBackground(Color.red);
private void yellow()
messagePanel.setBackground(Color.yellow);
private void blue()
messagePanel.setBackground(Color.blue);
private void orange()
messagePanel.setBackground(Color.orange);
//text color methods :)
private void redText()
messagePanel.setForeground(Color.red);
private void yellowText()
messagePanel.setForeground(Color.yellow);
private void blueText()
messagePanel.setForeground(Color.blue);
private void orangeText()
messagePanel.setForeground(Color.orange);
private void helvetica()
Font myfont = new Font("Helvetica", Font.PLAIN,12);
messagePanel.setFont(myfont);
private void courier()
Font myfont = new Font("Courier", Font.PLAIN,12);
messagePanel.setFont(myfont);
private void times()
Font myfont = new Font("TimesRoman", Font.PLAIN,12);
messagePanel.setFont(myfont);
private void symbol()
Font myfont = new Font("Symbol", Font.PLAIN,12);
messagePanel.setFont(myfont);You add everything to the Panel p but you never add that panel to the applet. What you probably want is to add everything to the applet. An applet is a special kind of panel so you can just change "p" to "this" everywhere in init and remove the declaration of p at the top.
-
My adobe captivate6 installs but does not run on my windows7 dell inspiron
my adobe captivate6 installs but does not run on my windows7 dell inspiron with 4gb ram and 500gb hdsk, i downloaded the trial first 32bit and it installed fine and didnt run. so i thought that a full version with a 64bit installation will do the trick, but after that the captivate 6 did not still work on my system. i also tried it on an acer with duo core and the captivate software installed and did not still work. it only shows the captivate flash screen.
a friend installed his on an acer laptop 64bit, i3processor, and it works fine. please i will be glad if i can be helped on how to correct this
thanksHave you tried right clicking on the Cp icon and selecting Run as Administrator? This is something you MUST do in Win7 but was not necessary on Xp.
-
Compiles but does not execute as expected????
Here is my code. I can compile and execute but does not perform as expected What do I need to change?
import java.io.;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.NumberFormat;
import java.math.*;
public class CalcTest extends JFrame implements ActionListener, ItemListener
public JMenuBar createMenuBar()
JMenuBar mnuBar = new JMenuBar();
setJMenuBar(mnuBar);
//Create File & add Exit
JMenu mnuFile = new JMenu("File", true);
mnuFile.setMnemonic(KeyEvent.VK_F);
mnuFile.setDisplayedMnemonicIndex(0);
mnuBar.add(mnuFile);
JMenuItem mnuFileExit = new JMenuItem("Exit");
mnuFileExit.setMnemonic(KeyEvent.VK_F);
mnuFileExit.setDisplayedMnemonicIndex(1);
mnuFile.add(mnuFileExit);
mnuFileExit.setActionCommand("Exit");
mnuFileExit.addActionListener(this);
JMenu mnuFunction = new JMenu("Function", true);
mnuFunction.setMnemonic(KeyEvent.VK_F);
mnuFunction.setDisplayedMnemonicIndex(0);
mnuBar.add(mnuFunction);
JMenuItem mnuFunctionClear = new JMenuItem("Clear");
mnuFunctionClear.setMnemonic(KeyEvent.VK_F);
mnuFunctionClear.setDisplayedMnemonicIndex(1);
mnuFunction.add(mnuFunctionClear);
mnuFunctionClear.setActionCommand("Clear");
mnuFunctionClear.addActionListener(this);
// Fields for Principle
JPanel row1 = new JPanel();
JLabel dollar = new JLabel("How much are you borrowing?");
JTextField money = new JTextField("", 15);
// Fields for Term and Rate
JPanel row2 = new JPanel();
JLabel choice = new JLabel("Select Year & Rate:");
JCheckBox altchoice = new JCheckBox("Alt. Method");
JTextField YR = new JTextField("", 4);
JTextField RT = new JTextField("", 4);
//Jcombobox R=rate,Y=year
String[] RY = {
"7 years at 5.35%", "15 years at 5.5 %", "30 years at 5.75%", " "
JComboBox mortgage = new JComboBox(RY);
// Fields for Payment
JPanel row3 = new JPanel();
JLabel payment = new JLabel("Your monthly payment will be:");
JTextField owe = new JTextField(" ", 15);
//Scroll Pane and Text Area
JPanel row4 = new JPanel();
JLabel amortization = new JLabel("Amortization:");
JTextArea chart = new JTextArea(" ", 7, 22);
JScrollPane scroll = new JScrollPane(chart, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
StringBuffer amt = new StringBuffer();
Container pane = getContentPane();
FlowLayout flow = new FlowLayout(FlowLayout.LEFT);
JButton Cal = new JButton("Calculate");
NumberFormat currency = NumberFormat.getCurrencyInstance();
public CalcTest()
// Title and Exit of JFrame
super("Mortgage and Amortization Calculator");
setSize(475, 328);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//JFrame layout
pane.setLayout(flow);
//Input output fields added to JFrame
row1.add(dollar);
row1.add(money);
pane.add(row1);
mortgage.setSelectedIndex(3);
mortgage.addActionListener(this);
mortgage.setActionCommand("mortgage");
row2.add(altchoice);
altchoice.addItemListener(this);
row2.add(choice);
YR.setEditable(false);
RT.setEditable(false);
row2.add(YR);
row2.add(RT);
row2.add(mortgage);
pane.add(row2);
row3.add(payment);
row3.add(owe);
pane.add(row3);
owe.setEditable(false);
//Scroll Pane added to JFrame
row4.add(amortization);
chart.setEditable(false);
row4.add(scroll);
pane.add(row4);
//Executable Button- Clear,Exit, Calculate
JPanel row5 = new JPanel();
JButton clear = new JButton("Clear");
clear.addActionListener(this);
row5.add(clear);
pane.add(row5);
JButton exit = new JButton("Exit");
exit.addActionListener(this);
row5.add(exit);
Cal.setEnabled(false);
Cal.addActionListener(this);
row5.add(Cal);
pane.add(row5);
setContentPane(pane);
setVisible(true);
} //End of constructor
private void calculate()
String loanAmount = money.getText();
if(loanAmount.equals(""))
return;
double P = Double.parseDouble(loanAmount);
int y;
double r;
if(altchoice.isSelected())
if(YR.getText().equals("") || RT.getText().equals(""))
return;
y = Integer.parseInt(YR.getText());
r = Double.parseDouble(RT.getText());
else
int index = mortgage.getSelectedIndex();
if(index == 3)
return;
int[] terms = { 7, 15, 30 };
double[] rates = { 5.5, 5.35, 5.75 };
y = terms[index];
r = rates[index];
double In = r / (100 * 12.0);
double M = P * (In / (1 - Math.pow(In + 1, -12.0 * y)));
owe.setText(currency.format(M));
//Column Titles for Text Area
chart.setText("Pmt#\tPrincipal\tInterest\tBalance\n");
for (int i = 0; i < y * 12; i++)
{ double interestAccrued = P * In;
double principalPaid = M - interestAccrued;
chart.append(i + 1 + "\t" + currency.format(principalPaid)
+ "\t" + currency.format(interestAccrued)
+ "\t" + currency.format(P) + "\n");
P = P + interestAccrued - M;
public void itemStateChanged(ItemEvent ie)
{ int status = ie.getStateChange();
if (status == ItemEvent.SELECTED)
mortgage.setEnabled(false);
YR.setEditable(true);
RT.setEditable(true);
Cal.setEnabled(true);
else
mortgage.setEnabled(true);
YR.setEditable(false);
RT.setEditable(false);
Cal.setEnabled(false);
public void actionPerformed(ActionEvent ae)//Calculations and Button executions
String command = ae.getActionCommand();
// Exit program
if (command.equals("Exit"))
System.exit(0);
// Cal button
if (command.equals("Calculate") || command.equals("mortgage"))
calculate();
// Clear fields
if (command.equals("Clear"))
money.setText(null);
mortgage.setSelectedIndex(3);
owe.setText(null);
chart.setText(null);
} //End actionPerformed
public static void main(String args[]) throws IOException
new CalcTest();
[/Code]Here is the code again
import java.io.;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.NumberFormat;
import java.math.*;
public class CalcTest extends JFrame implements ActionListener, ItemListener
public JMenuBar createMenuBar()
JMenuBar mnuBar = new JMenuBar();
setJMenuBar(mnuBar);
//Create File & add Exit
JMenu mnuFile = new JMenu("File", true);
mnuFile.setMnemonic(KeyEvent.VK_F);
mnuFile.setDisplayedMnemonicIndex(0);
mnuBar.add(mnuFile);
JMenuItem mnuFileExit = new JMenuItem("Exit");
mnuFileExit.setMnemonic(KeyEvent.VK_F);
mnuFileExit.setDisplayedMnemonicIndex(1);
mnuFile.add(mnuFileExit);
mnuFileExit.setActionCommand("Exit");
mnuFileExit.addActionListener(this);
JMenu mnuFunction = new JMenu("Function", true);
mnuFunction.setMnemonic(KeyEvent.VK_F);
mnuFunction.setDisplayedMnemonicIndex(0);
mnuBar.add(mnuFunction);
JMenuItem mnuFunctionClear = new JMenuItem("Clear");
mnuFunctionClear.setMnemonic(KeyEvent.VK_F);
mnuFunctionClear.setDisplayedMnemonicIndex(1);
mnuFunction.add(mnuFunctionClear);
mnuFunctionClear.setActionCommand("Clear");
mnuFunctionClear.addActionListener(this);
// Fields for Principle
JPanel row1 = new JPanel();
JLabel dollar = new JLabel("How much are you borrowing?");
JTextField money = new JTextField("", 15);
// Fields for Term and Rate
JPanel row2 = new JPanel();
JLabel choice = new JLabel("Select Year & Rate:");
JCheckBox altchoice = new JCheckBox("Alt. Method");
JTextField YR = new JTextField("", 4);
JTextField RT = new JTextField("", 4);
//Jcombobox R=rate,Y=year
String[] RY = {
"7 years at 5.35%", "15 years at 5.5 %", "30 years at 5.75%", " "
JComboBox mortgage = new JComboBox(RY);
// Fields for Payment
JPanel row3 = new JPanel();
JLabel payment = new JLabel("Your monthly payment will be:");
JTextField owe = new JTextField(" ", 15);
//Scroll Pane and Text Area
JPanel row4 = new JPanel();
JLabel amortization = new JLabel("Amortization:");
JTextArea chart = new JTextArea(" ", 7, 22);
JScrollPane scroll = new JScrollPane(chart, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
StringBuffer amt = new StringBuffer();
Container pane = getContentPane();
FlowLayout flow = new FlowLayout(FlowLayout.LEFT);
JButton Cal = new JButton("Calculate");
NumberFormat currency = NumberFormat.getCurrencyInstance();
public CalcTest()
// Title and Exit of JFrame
super("Mortgage and Amortization Calculator");
setSize(475, 328);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//JFrame layout
pane.setLayout(flow);
//Input output fields added to JFrame
row1.add(dollar);
row1.add(money);
pane.add(row1);
mortgage.setSelectedIndex(3);
mortgage.addActionListener(this);
mortgage.setActionCommand("mortgage");
row2.add(altchoice);
altchoice.addItemListener(this);
row2.add(choice);
YR.setEditable(false);
RT.setEditable(false);
row2.add(YR);
row2.add(RT);
row2.add(mortgage);
pane.add(row2);
row3.add(payment);
row3.add(owe);
pane.add(row3);
owe.setEditable(false);
//Scroll Pane added to JFrame
row4.add(amortization);
chart.setEditable(false);
row4.add(scroll);
pane.add(row4);
//Executable Button- Clear,Exit, Calculate
JPanel row5 = new JPanel();
JButton clear = new JButton("Clear");
clear.addActionListener(this);
row5.add(clear);
pane.add(row5);
JButton exit = new JButton("Exit");
exit.addActionListener(this);
row5.add(exit);
Cal.setEnabled(false);
Cal.addActionListener(this);
row5.add(Cal);
pane.add(row5);
setContentPane(pane);
setVisible(true);
} //End of constructor
private void calculate()
String loanAmount = money.getText();
if(loanAmount.equals(""))
return;
double P = Double.parseDouble(loanAmount);
int y;
double r;
if(altchoice.isSelected())
if(YR.getText().equals("") || RT.getText().equals(""))
return;
y = Integer.parseInt(YR.getText());
r = Double.parseDouble(RT.getText());
else
int index = mortgage.getSelectedIndex();
if(index == 3)
return;
int[] terms = { 7, 15, 30 };
double[] rates = { 5.5, 5.35, 5.75 };
y = terms[index];
r = rates[index];
double In = r / (100 * 12.0);
double M = P * (In / (1 - Math.pow(In + 1, -12.0 * y)));
owe.setText(currency.format(M));
//Column Titles for Text Area
chart.setText("Pmt#\tPrincipal\tInterest\tBalance\n");
for (int i = 0; i < y * 12; i++)
{ double interestAccrued = P * In;
double principalPaid = M - interestAccrued;
chart.append(i + 1 + "\t" + currency.format(principalPaid)
+ "\t" + currency.format(interestAccrued)
+ "\t" + currency.format(P) + "\n");
P = P + interestAccrued - M;
public void itemStateChanged(ItemEvent ie)
{ int status = ie.getStateChange();
if (status == ItemEvent.SELECTED)
mortgage.setEnabled(false);
YR.setEditable(true);
RT.setEditable(true);
Cal.setEnabled(true);
else
mortgage.setEnabled(true);
YR.setEditable(false);
RT.setEditable(false);
Cal.setEnabled(false);
public void actionPerformed(ActionEvent ae)//Calculations and Button executions
String command = ae.getActionCommand();
// Exit program
if (command.equals("Exit"))
System.exit(0);
// Cal button
if (command.equals("Calculate") || command.equals("mortgage"))
calculate();
// Clear fields
if (command.equals("Clear"))
money.setText(null);
mortgage.setSelectedIndex(3);
owe.setText(null);
chart.setText(null);
} //End actionPerformed
public static void main(String args[]) throws IOException
new CalcTest(); -
This program is well compiled but does not work.
I would like to know why this program does not work properly:
the idea is :
1. the user introduces a text as a string
2.the progam creates a file (with a FileOutputStream)
3. then this file is encripted according to DES (using JCE, cipheroutputStream)
4.the new filw is an encripte file, whose content is introduced in a string (with a FileInputStream)
(gives no probles of compilation!!)
(don know why it does not work)
here goes the code:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.io.*;
import java.security.*;
import javax.crypto.*;
public class cuadro extends Applet{
private TextArea area1 =new TextArea(5,50);
private TextArea area2 =new TextArea(5,50);
private Button encriptar=new Button("encriptar");
private Button decriptar=new Button("decriptar");
public cuadro(){
layoutApplet();
encriptar.addActionListener(new ButtonHandler());
decriptar.addActionListener(new ButtonHandler());
resize(400,400);
private void layoutApplet(){
Panel keyPanel = new Panel();
keyPanel.add(encriptar);
keyPanel.add(decriptar);
Panel textPanel = new Panel();
Panel texto1 = new Panel();
Panel texto2 = new Panel();
texto1.add(new Label(" plain text"));
texto1.add(area1);
texto2.add(new Label(" cipher text"));
texto2.add(area2);
textPanel.setLayout(new GridLayout(2,1));
textPanel.add(texto1);
textPanel.add(texto2);
setLayout(new BorderLayout());
add("North", keyPanel);
add("Center", textPanel);
public static String encriptar(String text1){
//generar una clave
SecretKey clave=null;
String text2="";
try{
FileOutputStream fs =new FileOutputStream ("c:/javasoft/ti.txt");
DataOutputStream es= new DataOutputStream(fs);
for(int i=0;i<text1.length();++i){
int j=text1.charAt(i);
es.write(j);
es.close();
}catch(IOException e){
System.out.println("no funciona escritura");
}catch(SecurityException e){
System.out.println("el fichero existe pero es un directorio");
try{
//existe archivo DESkey.ser?
ObjectInputStream claveFich =new ObjectInputStream(new FileInputStream ("DESKey.ser"));
clave = (SecretKey) claveFich.readObject();
claveFich.close();
}catch(FileNotFoundException e){
System.out.println("creando DESkey.ser");
//si no, generar generar y guardar clave nueva
try{
KeyGenerator claveGen = KeyGenerator.getInstance("DES");
clave= claveGen.generateKey();
ObjectOutputStream claveFich = new ObjectOutputStream(new FileOutputStream("DESKey.ser"));
claveFich.writeObject(clave);
claveFich.close();
}catch(NoSuchAlgorithmException ex){
System.out.println("DES key Generator no encontrado.");
System.exit(0);
}catch(IOException ex){
System.out.println("error al salvar la clave");
System.exit(0);
}catch(Exception e){
System.out.println("error leyendo clave");
System.exit(0);
//crear una cifra
Cipher cifra = null;
try{
cifra= Cipher.getInstance("DES/ECB/PKCS5Padding");
cifra.init(Cipher.ENCRYPT_MODE,clave);
}catch(InvalidKeyException e){
System.out.println("clave no valida");
System.exit(0);
}catch(Exception e){
System.out.println("error creando cifra");
System.exit(0);
//leer y encriptar el archivo
try{
DataInputStream in = new DataInputStream(new FileInputStream("c:/javasoft/ti.txt"));
CipherOutputStream out = new CipherOutputStream(new DataOutputStream(new FileOutputStream("c:/javasoft/t.txt")),cifra);
int i;
do{
i=in.read();
if(i!=-1) out.write(i);
}while (i!=-1);
in.close();
out.close();
}catch(IOException e){
System.out.println("error en lectura y encriptacion");
System.exit(0);
try{
FileInputStream fe=new FileInputStream("c:/javasoft/t.txt");
DataInputStream le =new DataInputStream(fe);
int i;
char c;
do{
i=le.read();
c= (char)i;
if(i!=-1){
text2 += text2.valueOf(c);
}while(i!=-1);
le.close();
/*}catch(FileNotFoundException e){
System.out.println("fichero no encontrado");
System.exit(0);
}catch(ClassNotFoundException e){
System.out.println("clase no encontrada");
System.exit(0);
*/}catch(IOException e){
System.out.println("error e/s");
System.exit(0);
return text2;
class ButtonHandler implements ActionListener{
public void actionPerformed(ActionEvent e){
try{
if (e.getActionCommand().equals(encriptar.getLabel()))
// area2.setText(t1)
area2.setText(encriptar(area1.getText()));
//area2.setText("escribe algo");
else if (e.getActionCommand().equals(decriptar.getLabel()))
System.out.println("esto es decriptar");
//area2.setText("hola");
}catch(Exception ex){
System.out.println("error en motor de encriptacion");
//else System.out.println("no coge el boton encriptado/decript");If you don't require your code to run as an applet, you will probably get more mileage from refactoring it to run as an application.
As sudha_mp implied, an unsigned applet will fail on the line
FileInputStream fe=new FileInputStream("c:/javasoft/t.txt");
due to security restrictions. (Which, incidentally, are there for a very good reason) -
I am trying to do all of my work in Visual Studio 2013, but I have found that, in one case (at least), if I compile the project in VS 2013 or VS 2012, I get the error "Could
not load file or assembly 'NationalInstruments.DAQmx, Version=9.4.40.50, Culture=neutral, PublicKeyToken=dc6ad606294fc298'
or one of its dependencies. The system cannot find the file specified."
Yes, I am loading a third party DLL and here's what is strange... If I compile it with VS2010, I have no problem - the program works correctly - no errors. If I take the same solution and load it in VS2012 or VS2013, it compiles cleanly and looks good (no
errors and no warnings) - until I run it.
So, how do I get this to work with VS2013? And what changed? And with the number of developers in this company - it HAS to work with VS2010, 2012 and 2013 (different developers have different licenses), so how do I get that and how do I ensure that
future development does not have this problem?
The project targets .NET framework 4.
RobHi,
If the error occurred at a third-party dll, then it is out of support range of forums. Please consult your issue on the forums/communities provided by the third-party dll for better solutions and support.
Moreover VS General Question forum mainly discusses
the usage of Visual Studio IDE such as WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System
and Visual Studio Editor.
Best regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
My program compiles but when i run it, main class cannot be found
as you can see, my program TestMaker compiles but when i try running it i get all these errors, i have no idea what's wrong with this
C:\Users\Student\workspace\TestMaker\src>javac TestMaker.java
C:\Users\Student\workspace\TestMaker\src>java TestMaker 514pcp.txt
Exception in thread "main" java.lang.NoClassDefFoundError: TestMaker
Caused by: java.lang.ClassNotFoundException: TestMaker
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: TestMaker. Program will exit.
C:\Users\Student\workspace\TestMaker\src>jgv9a wrote:
So i try
java -cp . TestMaker 514pcp.txt
and get this
C:\Users\Student\workspace\TestMaker\src>java -cp . TestMaker 514.txt
Exception in thread "main" java.lang.NoClassDefFoundError: StdInThat means that you are using a class (StdIn), that is not on your classpath, but in some other place.
The "-cp ." tells Java to ignore the CLASSPATH variable and just look in the current directory instead. You probably had the location of StdIn on your CLASSPATH variable.
What you need to do in this case is to add the current directory "." to your CLASSPATH variable.
Go [learn about the Classpath here|http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html]. -
Java program compiles but failes to run
WHAT IS WRONG WITH THIS PROGRAM? It compiles;
however, when I try to run it, I get the message"
static void main not define in class car. Please help!
class Car {
int passanger;
int mpg;
int gas;
void range() {
System.out.println("Distance of =:" + mpg*gas);
class Models {
public static void main(String args[]) {
Car Toyata=new Car();
Car Mazada=new Car();
Toyata.passanger=8;
Mazada.passanger=6;
Toyata.mpg=30;
Mazada.mpg=25;
Toyata.gas=16;
Mazada.gas=17;
System.out.println("Toyata can carry" +Toyata.passanger);
Toyata.range();The program gets compiled into two classes: Car.class & Models.class.
class Car {
int passanger;
int mpg;
int gas;
void range() {
System.out.println("Distance of =:" + mpg*gas);
class Models {
public static void main(String args[]) {
Car Toyata=new Car();
Car Mazada=new Car();
Toyata.passanger=8;
Mazada.passanger=6;
Toyata.mpg=30;
Mazada.mpg=25;
Toyata.gas=16;
Mazada.gas=17;
System.out.println("Toyata can carry" +Toyata.passanger);
Toyata.range();
java Car does not produce output because the main method is in the Models.class.
java Modelsproduces output
Toyaota can carry 8
Distance of :=480 -
When I run set up... it extracts files somewhere but does not run
When downloading firefox set up software and runnning it... nothing happens... the files appear to extract, but the set up program does not run
Have you followed the instructions in [[Installing Firefox on Windows]]
Are you able to follow the instructions and use an Administrative account, turn off UAC and disable security software ?
Do you get any error reports ? -
This Formula(Function) compiles but does not display any result
Please can anybody help me resolve this issue.The code below is a code for a formula(function) column in oracle report, i have complied this code and it successfully complied but it does not display any result for the column having a stock balance in the entire report.
function CF_STOCK_BALFormula return Number is
v_all_positive NUMBER;
v_all_negative NUMBER;
begin
IF :transaction_type IN ('RECEIPT', 'RETURN') THEN
IF :cp_stock_bal IS NULL OR :cp_stock_bal = 0 THEN
:cp_stock_bal := :opening_balance + :cp_stock_bal + :quantity;
ELSE
:cp_stock_bal := :cp_stock_bal + :quantity;
END IF;
ELSIF :transaction_type IN ('ISSUE') THEN
IF :cp_stock_bal IS NULL OR :cp_stock_bal = 0 THEN
:cp_stock_bal := :opening_balance + :cp_stock_bal - :quantity;
ELSE
:cp_stock_bal := :cp_stock_bal - :quantity;
END IF;
END IF;
RETURN (:cp_stock_bal);
end;
Edited by: Gbenga on Jan 17, 2012 11:30 PMPlease can anybody help me resolve this issue.The code below is a code for a formula(function) column in oracle report, i have complied this code and it successfully complied but it does not display any result for the column having a stock balance in the entire report.
function CF_STOCK_BALFormula return Number is
v_all_positive NUMBER;
v_all_negative NUMBER;
begin
IF :transaction_type IN ('RECEIPT', 'RETURN') THEN
IF :cp_stock_bal IS NULL OR :cp_stock_bal = 0 THEN
:cp_stock_bal := :opening_balance + :cp_stock_bal + :quantity;
ELSE
:cp_stock_bal := :cp_stock_bal + :quantity;
END IF;
ELSIF :transaction_type IN ('ISSUE') THEN
IF :cp_stock_bal IS NULL OR :cp_stock_bal = 0 THEN
:cp_stock_bal := :opening_balance + :cp_stock_bal - :quantity;
ELSE
:cp_stock_bal := :cp_stock_bal - :quantity;
END IF;
END IF;
RETURN (:cp_stock_bal);
end;
Edited by: Gbenga on Jan 17, 2012 11:30 PM -
ITunes installs but does not run on Windows 7 64-bit
I've spent a couple hours going over advice on this forum as well as elsewhere on the Internet to resolve this. iTunes installs without a problem but when we run it, nothing appears. iTunes.exe *32 and iTunesHelper.exe *32 appear in the Windows Task Manager but there is no other evidence that iTunes is running.
I've tried installing and reinstalling. I've tried a number of different compatibility settings. Surely there must be an easy way to resolve this.
Frustrated,
AndyThe problem, as it turns out, is Bonjour. See http://discussions.apple.com/thread.jspa?threadID=2408851&tstart=0 for ideas on how to fix....
-
Lightroom CC installed but does not run
The CC update has run and I now have Lightroom CC installed .... or so I thought.
I have a new shortcut for LR but it does nothing.
My old LR 5.7.1 still works - if I open this and check for updates it says it is up to date.
The new LR link is "C:\Program Files\Adobe\Adobe Lightroom\lightroom.exe"
After the LR update, CC said it needed updating so I did the update.
It now says I have the following apps installed ...
Photoshop CC Update Ready
Photoshop CC (2014) Update Ready
Bridge CC Update Ready
Lightroom 5 Up to date
Lightroom CC (2015) Up to date
Edge Inspect CC Up to date
I am not aware of any updates for the first 3 items
I presume the multiple copies of versions may be part of the problem.
Any idea how I proceed?It seems to have worked ! I was doubtful since I had already rebooted so I thought that would resolve things.
After the logout/login, I launched LR and updated my default catalogue. Then notified me that a third-party plugin was no longer compatible (no problem, I dont use it anyway)
Now it is working
Thanks. -
Old C socket program compiles, but doesn't run properly
I have an old C program that uses sys/ipc.h to listen on ports 6666 and ports 6669 for user requests. I have determined that the
program gets to the 'accept' call without error. The return from accept(sockfd, (struct sockaddr *) &cli_addr, &cli_addrlen) is zero
indicating success. Nevertheless, something is wrong, because netstat -a shows nothing listening on either 6666 or 6669, and
telnet to these two ports fails as well.
I've compiled and run the program on Sparc 8 and 9. It is the i86pc architecture I am having a problem with. I tried having root
run it in the global zone in order to eliminate zones as a factor with no success.
This program also uses threads (thread.h) and rpc (rpc.h). Has anyone seen this problem? Does anyone have a suggestion?
GeorgeHi Darren:
Thanks for your prompt supply. I saw no alternative but to start pulling the code apart and I believe I have a solution. I think big-endian as opposed to
little-endian definitely has something to do with it.
Here's what I had to change to make this work:
Original Code: serv_addr.sin_port = htonl(port);
Modified Code: serv_addr.sin_port = htons((short) port);
Converting the port to a short seems to have fixed things. The original code converted the port to a long. -
Group Policy Startup Script Applies My Policy But Does Not Run The Acual Scripts
I have created a basic batch file with msiexec.exe to uninstall a program on startup and then another separate .bat script to install the same program but the newer version. The software I'm referring to has to be completely uninstalled BEFORE
I install the "newer" version of the same program, it cannot just be overwritten. If I run a gpupdate /force on the client computer and restart, the scripts run as they are supposed to and everything works but the problem is that I can't get it to
run on first boot on a computer that has been turned off for months, even after multiple reboots it still doesn't run the scripts. The 3 policies apply to the different computers/users but the scripts don't run. I manage a theme park that is
only open 4 months of the year so the rest of the time the in park PC's are turned off. I have created my OU as "POS Computers & Users" which has all of the computers and users that will take this policy. I also have 3 Group Policy
Objects attached to this OU in Group Policy, 1 is the program uninstallation .bat script policy that runs on startup, 2 is the install .bat script policy that runs after the uninstallation script, and 3 is the Default Policy for the OU. I already have the
"Always wait for the network at computer startup and logon", "Run startup scripts visible"enabled, "Run startup scripts asynchronously" disabled, and "Run Logon Scripts Synchronously" enabled for all 3 of the
policies. They are all "link enabled" and security filtering is set to only the OU I mentioned earlier so that it doesn't affect anyone else. I have the link order set as the script I want to run first as the last and the one I want to run last first
because from what I understand inheritance is from bottom to top. The install file is accessible by everyone with full permissions on our "Shared" drive so I know its not a permissions issue because it runs after a gpupdate /force with a restart.
The scripts are in the proper folder for the policies they are attached to and permissions are fine.
Here is my uninstall .bat script (msiexec.exe /X{14324A6A-BDD1-4F40-8E77-664C8AEEA251} /forcerestart /qb-! ALLUSERS=1 REMOVE=ALL)
Here is my install .bat script (msiexec.exe /i {\\kksrvad\shared\Gatemaster\NewGatemaster.msi} /qb ALLUSERS=1)Can't be done in a login script.
This is a Group Policy issue and not a scripting issue. You do not have a script. You have a command saved in a batch file and you are using a GPO. Not a scripting issue.
¯\_(ツ)_/¯
Maybe you are looking for
-
Hi How to trasport material from Sale order stock to Subcontractor? Raju
-
How do i make my hp laser jet p1102w printer wireless using bright house modem
How do I make my printer wireless without having to hook the computer to the printer. I have the Bright house moden and internet services.
-
Expand/Collapse all the Bookmarks in a PDF file
Hi, This is my first message on the board :-) I work with very large PDF files (i.e 2000 pages, 700 bookmarks on 5 or 6 levels!) and I'm looking for a script (Acrobat 9 Pro) allowing to expand/collapse all the bookmarks in a PDF file. Thanks in advan
-
Flashback Database on Data Guard setup
Hello! Win 2003 server - 64 bit Oracle 10.2.0.4 As i have noticed Flashback Database is popular in Data Guard setups for the reinstate reason; you dont need to rebuild. However, im looking at Flashback for 'flashback database' reasons. Some developer
-
Hi , To improve the performance of the insert statement i was adviced to use the collections. I'm not getting any idea on how to use collection concept in my code. Could you please give me a skelton approach to do that. The following is the sample co