Why am i not able to run this program ??
When i exec a single process it works fine but when i try to execute array of commands i couldn't it complies but doesn't execute any 1 of the commands.
Please let me know
import java.io.IOException;
class RunTime
public static void main(String raja[])
Runtime r = Runtime.getRuntime();
Process p;
String[] commands = { "notepad","calcic","mspaint"};
System.out.println("Executing processes please wait........");
try
int commandslength = commands.length;
for(int i = 0 ; i < commandslength ; i++)
p = r.exec("commands");
catch(Exception e)
System.out.println("Cant proceed furthur ..");
Instead ofp = r.exec("commands");dop = r.exec(commands);Next time please paste your code between [code] tags with the help of the code button just above the edit message area.
It makes the code MUCH more readable.
Regards
Similar Messages
-
Could not able to RUN Java Programs in JRE 1.5.08
hi
I am using Jdk 1.5.8.
I don�t have any problem in compiling the files.
but i could not able to run the program through windows cmd prompt.
Say name of the java file is newFile (no packages).
When i try to run the program by using java newFile it raises a ClassNotFoundException.
it s the same case when try to set any JDBC drivers ..
is there any problem in my class path settings? Please help me out to fix this problemif your current directory is not in the classpath,you should include it in the classpath.
To do that you can include .(dot) to your classpath variable.
http://java.sun.com/j2se/1.3/docs/tooldocs/win32/classpath.html -
Not able to run python programs on OSx maverics
I bought Mac book pro 1.5 yrs back, and it came with OSx 10.6 now few months back I upgraded to OSx maverics and since then I am not able to run python tools properly. Just importing something in the python commandline i get segmentation fault 11.
now I just tried
import os
and i got segmentation fault with below error,
Process:
Python [1230]
Path:
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/ MacOS/Python
Identifier:
Python
Version:
2.7.4 (2.7.4)
Code Type:
X86-64 (Native)
Parent Process: bash [883]
Responsible:
Terminal [749]
User ID:
501
Date/Time:
2015-01-15 09:46:08.784 +0530
OS Version:
Mac OS X 10.9.2 (13C64)
Report Version: 11
Anonymous UUID: A975CB81-1635-0611-4AD9-0DC61C4EC9A0
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
VM Regions Near 0:
-->
__TEXT
0000000100000000-0000000100001000 [
4K] r-x/rwx SM=COW /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents /MacOS/Python
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 readline.so
0x00000001002f2f97 call_readline + 647
1 org.python.python
0x0000000100008e92 PyOS_Readline + 274
2 org.python.python
0x000000010000a6e8 tok_nextc + 104
3 org.python.python
0x000000010000ae93 PyTokenizer_Get + 147
4 org.python.python
0x0000000100005a8a parsetok + 218
5 org.python.python
0x00000001000e8af2 PyParser_ASTFromFile + 146
6 org.python.python
0x00000001000e9dd3 PyRun_InteractiveOneFlags + 243
7 org.python.python
0x00000001000ea0be PyRun_InteractiveLoopFlags + 78
8 org.python.python
0x00000001000ea8d1 PyRun_AnyFileExFlags + 161
9 org.python.python
0x000000010010155d Py_Main + 3101
10 org.python.python
0x0000000100000f14 0x100000000 + 3860
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x0000000100322290 rcx: 0x0000000102000000 rdx: 0x0000000000000a00
rdi: 0x0000000000000000 rsi: 0x00000001002f3254 rbp: 0x00007fff5fbff2d0 rsp: 0x00007fff5fbff200
r8: 0x0000000102000000 r9: 0x0000000000000000 r10: 0x0080002140000003 r11: 0x0000000000000001
r12: 0x0000000000000001 r13: 0x0000000000000009 r14: 0x00007fff5fbff290 r15: 0x00007fff5fbff210
rip: 0x00000001002f2f97 rfl: 0x0000000000010206 cr2: 0x0000000000000000
Logical CPU:
1
Error Code:
0x00000004
Trap Number:
14
Binary Images:
0x100000000 -
0x100000fff +org.python.python (2.7.4 - 2.7.4) <A450FF23-FAE2-B1D7-E70F-5511C3FAD379> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents /MacOS/Python
0x100003000 -
0x10016fff7 +org.python.python (2.7.4, [c] 2004-2013 Python Software Foundation. - 2.7.4) <D4B4F67F-D7AA-AECF-2E7C-6C605A9B1EA9> /Library/Frameworks/Python.framework/Versions/2.7/Python
0x1002f1000 -
0x1002f3fff +readline.so (???) <CDBF1919-7992-8A7E-5F30-D429DB67EF51> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/rea dline.so
0x100700000 -
0x10071effb libedit.2.dylib (39) <1B0596DB-F336-32E7-BB9F-51BF70DB5305> /usr/lib/libedit.2.dylib
0x10072f000 -
0x100783fe7 +libncursesw.5.dylib (5) <3F0079C0-01C1-3CB8-19CA-F9B49AA4F4A4> /Library/Frameworks/Python.framework/Versions/2.7/lib/libncursesw.5.dylib
0x7fff64d5d000 -
0x7fff64d90817 dyld (239.4) <2B17750C-ED1B-3060-B64E-21897D08B28B> /usr/lib/dyld
0x7fff88329000 -
0x7fff8833aff7 libsystem_asl.dylib (217.1.4) <655FB343-52CF-3E2F-B14D-BEBF5AAEF94D> /usr/lib/system/libsystem_asl.dylib
0x7fff8833b000 -
0x7fff88340ff7 libunwind.dylib (35.3) <78DCC358-2FC1-302E-B395-0155B47CB547> /usr/lib/system/libunwind.dylib
0x7fff88b16000 -
0x7fff88b3dff7 libsystem_network.dylib (241.3) <8B1E1F1D-A5CC-3BAE-8B1E-ABC84337A364> /usr/lib/system/libsystem_network.dylib
0x7fff88b3e000 -
0x7fff88b5aff7 libsystem_kernel.dylib (2422.90.20) <20E00C54-9222-359F-BD98-CB79ABED769A> /usr/lib/system/libsystem_kernel.dylib
0x7fff88de4000 -
0x7fff88e14fff libncurses.5.4.dylib (42) <BF763D62-9149-37CB-B1D2-F66A2510E6DD> /usr/lib/libncurses.5.4.dylib
0x7fff88e15000 -
0x7fff88e1bff7 libsystem_platform.dylib (24.90.1) <3C3D3DA8-32B9-3243-98EC-D89B9A1670B3> /usr/lib/system/libsystem_platform.dylib
0x7fff88e8c000 -
0x7fff88ea7ff7 libsystem_malloc.dylib (23.10.1) <A695B4E4-38E9-332E-A772-29D31E3F1385> /usr/lib/system/libsystem_malloc.dylib
0x7fff891a9000 -
0x7fff891f7fff libcorecrypto.dylib (161.1) <F3973C28-14B6-3006-BB2B-00DD7F09ABC7> /usr/lib/system/libcorecrypto.dylib
0x7fff892a2000 -
0x7fff892acfff libcommonCrypto.dylib (60049) <8C4F0CA0-389C-3EDC-B155-E62DD2187E1D> /usr/lib/system/libcommonCrypto.dylib
0x7fff892c0000 -
0x7fff89312fff libc++.1.dylib (120) <4F68DFC5-2077-39A8-A449-CAC5FDEE7BDE> /usr/lib/libc++.1.dylib
0x7fff8a0de000 -
0x7fff8a105ffb libsystem_info.dylib (449.1.3) <7D41A156-D285-3849-A2C3-C04ADE797D98> /usr/lib/system/libsystem_info.dylib
0x7fff8b079000 -
0x7fff8b080fff libcompiler_rt.dylib (35) <4CD916B2-1B17-362A-B403-EF24A1DAC141> /usr/lib/system/libcompiler_rt.dylib
0x7fff8b081000 -
0x7fff8b082ffb libremovefile.dylib (33) <3543F917-928E-3DB2-A2F4-7AB73B4970EF> /usr/lib/system/libremovefile.dylib
0x7fff8b083000 -
0x7fff8b23bff3 libicucore.A.dylib (511.31) <167DDD0A-A935-31AF-B5B9-940268EC3A3C> /usr/lib/libicucore.A.dylib
0x7fff8bb00000 -
0x7fff8bb2ffd2 libsystem_m.dylib (3047.16) <B7F0E2E4-2777-33FC-A787-D6430B630D54> /usr/lib/system/libsystem_m.dylib
0x7fff8c3a5000 -
0x7fff8c3a6ff7 libsystem_blocks.dylib (63) <FB856CD1-2AEA-3907-8E9B-1E54B6827F82> /usr/lib/system/libsystem_blocks.dylib
0x7fff8cd63000 -
0x7fff8cd65ff7 libquarantine.dylib (71) <7A1A2BCB-C03D-3A25-BFA4-3E569B2D2C38> /usr/lib/system/libquarantine.dylib
0x7fff8d8fa000 -
0x7fff8d923ff7 libc++abi.dylib (49.1) <21A807D3-6732-3455-B77F-743E9F916DF0> /usr/lib/libc++abi.dylib
0x7fff8dbcc000 -
0x7fff8dbd3ff7 libsystem_pthread.dylib (53.1.4) <AB498556-B555-310E-9041-F67EC9E00E2C> /usr/lib/system/libsystem_pthread.dylib
0x7fff8dbfb000 -
0x7fff8dbffff7 libcache.dylib (62) <BDC1E65B-72A1-3DA3-A57C-B23159CAAD0B> /usr/lib/system/libcache.dylib
0x7fff8ddf9000 -
0x7fff8de00ff8 liblaunch.dylib (842.90.1) <38D1AB2C-A476-385F-8EA8-7AB604CA1F89> /usr/lib/system/liblaunch.dylib
0x7fff8de01000 -
0x7fff8de43ff7 libauto.dylib (185.5) <F45C36E8-B606-3886-B5B1-B6745E757CA8> /usr/lib/libauto.dylib
0x7fff8de4d000 -
0x7fff8de51ff7 libsystem_stats.dylib (93.90.3) <1A55AF8A-B6C4-3163-B557-3AD25DA643A8> /usr/lib/system/libsystem_stats.dylib
0x7fff8ecd8000 -
0x7fff8eebdfff com.apple.CoreFoundation (6.9 - 855.14) <617B8A7B-FAB2-3271-A09B-C542E351C532> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x7fff90c81000 -
0x7fff90c89fff libsystem_dnssd.dylib (522.90.2) <A0B7CF19-D9F2-33D4-8107-A62184C9066E> /usr/lib/system/libsystem_dnssd.dylib
0x7fff90c8b000 -
0x7fff90c8cff7 libDiagnosticMessagesClient.dylib (100) <4CDB0F7B-C0AF-3424-BC39-495696F0DB1E> /usr/lib/libDiagnosticMessagesClient.dylib
0x7fff91b4f000 -
0x7fff91b54fff libmacho.dylib (845) <1D2910DF-C036-3A82-A3FD-44FF73B5FF9B> /usr/lib/system/libmacho.dylib
0x7fff91c4e000 -
0x7fff91c55ff3 libcopyfile.dylib (103) <5A881779-D0D6-3029-B371-E3021C2DDA5E> /usr/lib/system/libcopyfile.dylib
0x7fff91d91000 -
0x7fff91e1aff7 libsystem_c.dylib (997.90.3) <6FD3A400-4BB2-3B95-B90C-BE6E9D0D78FA> /usr/lib/system/libsystem_c.dylib
0x7fff91e6e000 -
0x7fff91e77ff3 libsystem_notify.dylib (121) <52571EC3-6894-37E4-946E-064B021ED44E> /usr/lib/system/libsystem_notify.dylib
0x7fff9272c000 -
0x7fff9272dff7 libsystem_sandbox.dylib (278.11) <5E5A6E09-33A9-391A-AB34-E57D93BB1551> /usr/lib/system/libsystem_sandbox.dylib
0x7fff92ede000 -
0x7fff92f02fff libxpc.dylib (300.90.2) <AB40CD57-F454-3FD4-B415-63B3C0D5C624> /usr/lib/system/libxpc.dylib
0x7fff93601000 -
0x7fff93602ff7 libSystem.B.dylib (1197.1.1) <BFC0DC97-46C6-3BE0-9983-54A98734897A> /usr/lib/libSystem.B.dylib
0x7fff9363c000 -
0x7fff937e9f27 libobjc.A.dylib (551.1) <AD7FD984-271E-30F4-A361-6B20319EC73B> /usr/lib/libobjc.A.dylib
0x7fff93b8e000 -
0x7fff93b8eff7 libkeymgr.dylib (28) <3AA8D85D-CF00-3BD3-A5A0-E28E1A32A6D8> /usr/lib/system/libkeymgr.dylib
0x7fff949e8000 -
0x7fff949ebff7 libdyld.dylib (239.4) <CF03004F-58E4-3BB6-B3FD-BE4E05F128A0> /usr/lib/system/libdyld.dylib
0x7fff94df0000 -
0x7fff94df2ff3 libsystem_configuration.dylib (596.13) <B51C8C22-C455-36AC-952D-A319B6545884> /usr/lib/system/libsystem_configuration.dylib
0x7fff95357000 -
0x7fff95358fff libunc.dylib (28) <62682455-1862-36FE-8A04-7A6B91256438> /usr/lib/system/libunc.dylib
0x7fff95380000 -
0x7fff95391ff7 libz.1.dylib (53) <42E0C8C6-CA38-3CA4-8619-D24ED5DD492E> /usr/lib/libz.1.dylib
0x7fff95392000 -
0x7fff953acfff libdispatch.dylib (339.90.1) <F3CBFE1B-FCE8-3F33-A53D-9092AB382DBB> /usr/lib/system/libdispatch.dylib
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 1192
thread_create: 0
thread_set_state: 0
VM Region Summary:
ReadOnly portion of Libraries: Total=76.9M resident=147.6M(192%) swapped_out_or_unallocated=16777216.0T(22877170565120%)
Writable regions: Total=46.0M written=2644K(6%) resident=3112K(7%) swapped_out=0K(0%) unallocated=42.9M(93%)
REGION TYPE
VIRTUAL
===========
=======
Kernel Alloc Once
4K
MALLOC
37.6M
MALLOC (admin)
16K
STACK GUARD
56.0M
Stack
8192K
VM_ALLOCATE
8K
__DATA
1432K
__LINKEDIT
66.2M
__TEXT
10.7M
__UNICODE
544K
shared memory
4K
===========
=======
TOTAL
180.5M
Model: MacBookPro9,2, BootROM MBP91.00D3.B06, 2 processors, Intel Core i5, 2.5 GHz, 4 GB, SMC 2.2f38
Graphics: Intel HD Graphics 4000, Intel HD Graphics 4000, Built-In, 1024 MB
Memory Module: BANK 0/DIMM0, 2 GB, DDR3, 1600 MHz, 0x02FE, 0x45424A3230554638424455302D474E2D4620
Memory Module: BANK 1/DIMM0, 2 GB, DDR3, 1600 MHz, 0x02FE, 0x45424A3230554638424455302D474E2D4620
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0xF5), Broadcom BCM43xx 1.0 (5.106.98.100.22)
Bluetooth: Version 4.2.3f10 13477, 3 services, 15 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en1
Serial ATA Device: APPLE HDD HTS547550A9E384, 500.11 GB
Serial ATA Device: HL-DT-ST DVDRW GS31N
USB Device: Hub
USB Device: Android
USB Device: FaceTime HD Camera (Built-in)
USB Device: Hub
USB Device: Hub
USB Device: IR Receiver
USB Device: Apple Internal Keyboard / Trackpad
USB Device: BRCM20702 Hub
USB Device: Bluetooth USB Host Controller
Thunderbolt Bus: MacBook Pro, Apple Inc., 25.1
I would really appreciate if some one can help solve the above issue.That is always a classpath issue. Fix your classpath so it uses the J2ee.jar. If you are using an IDE you will have to look up how to add JARs to the IDE's classpath, which is usually not the same as the system classpath.
-
I am not able to run a program,please help?
hi everybody,
i am getting run time error when trying to run this program, what's the wrong with that
i copied the mysql( mysql-connector-java-5.1.11-bin.jar) driver to the following:
C:\Program Files\Java\jre1.6.0_05\lib\ext
here is the code:
import java.sql.*;
public class Jdbc11 {
public static void main(String args[]){
System.out.println(
"java with mysql");
try {
Statement stmt;
Class.forName("com.mysql.jdbc.Driver");
String url ="jdbc:mysql://localhost:3306/mysql";
Connection con = DriverManager.getConnection(url,"root", "555");
System.out.println("URL: " + url);
System.out.println("Connection: " + con);
stmt = con.createStatement();
stmt.executeUpdate("CREATE DATABASE JunkDB");
stmt.executeUpdate(
"GRANT SELECT,INSERT,UPDATE,DELETE," +
"CREATE,DROP " +
"ON JunkDB.* TO 'auser'@'localhost' " +
"IDENTIFIED BY 'drowssap';");
con.close();
}catch( Exception e ) {
e.printStackTrace();
}//end catch
}//end main
}//end class Jdbc11
the error:
C:\New Folder>java Jdbc11
Exception in thread "main" java.lang.NoClassDefFoundError: Jdbc11
Caused by: java.lang.ClassNotFoundException: Jdbc11
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)This is a sub-optimal solution. Renaming a jar file to remove version information can cause problems later. How will you know the version for which you check documentation, bugs, etc? Also, the root directory of your file system is not the best place to put java archive files. It can get pretty crowded for a complex application. I suggest you create, for your project, some directory where third-party jar files can maintained. We do this for each project.
{? -
HT1222 Why am I not able to download this update. The submit button is shaded out?
My iPad states that there is a system update in SETTINGS >GENERAL and that its for iOS, but the submit button is shaded out so I can't perform the update!! Does anyone know why??
Are you Connected to WiFi?
-
Not able to run a program to extract news from news channel websites.
Let me start with stating the fact that I am a super greenhorn, so please be ultra elaborate with the answers .
This is my code, I copied it from Mr. Alvin Alexander (http://alvinalexander.com/java/edu/pj/pj010011?). I am trying to use it to extract news from news channel websites.
I used the following URLs:
1.http://in.reuters.com/
2.http://timesofindia.indiatimes.com/
3.http://www.hindustantimes.com/
// JavaGetUrl.java: //
// A Java program that demonstrates a procedure that can be //
// used to download the contents of a specified URL. //
// Code created by Developer's Daily //
// http://www.DevDaily.com //
import java.io.*;
import java.net.*;
public class JavaGetUrl {
public static void main (String[] args) {
// Step 1: Start creating a few objects we'll need.
URL u;
InputStream is = null;
DataInputStream dis;
String s;
try {
// Step 2: Create the URL. //
// Note: Put your real URL here, or better yet, read it as a //
// command-line arg, or read it from a file. //
u = new URL("http://200.210.220.1:8080/index.html");
// Step 3: Open an input stream from the url. //
is = u.openStream(); // throws an IOException
// Step 4: //
// Convert the InputStream to a buffered DataInputStream. //
// Buffering the stream makes the reading faster; the //
// readLine() method of the DataInputStream makes the reading //
// easier. //
dis = new DataInputStream(new BufferedInputStream(is));
// Step 5: //
// Now just read each record of the input stream, and print //
// it out. Note that it's assumed that this problem is run //
// from a command-line, not from an application or applet. //
while ((s = dis.readLine()) != null) {
System.out.println(s);
} catch (MalformedURLException mue) {
System.out.println("Ouch - a MalformedURLException happened.");
mue.printStackTrace();
System.exit(1);
} catch (IOException ioe) {
System.out.println("Oops- an IOException happened.");
ioe.printStackTrace();
System.exit(1);
} finally {
// Step 6: Close the InputStream //
try {
is.close();
} catch (IOException ioe) {
// just going to ignore this one
} // end of 'finally' clause
} // end of main
} // end of class definition
This is the error i am getting, every time I run it on Eclipse:
Oops- an IOException happened.
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at JavaGetUrl.main(JavaGetUrl.java:33)
Also, when I try a local server URL, the output screen goes blank, which I guess is due to lack of Text on the local URL. So, the little research that I did, made me believe that the code not running on external server was due to firewall on the server side. Please help me run it. Also : I work on a proxy network.( if that has something to do with this).
P.S : Advanced gratitude for any assistance.any decently secured server would reject such a blatant attempt to steal its content.
-
I am not able to compile this program because it has an compile error.
Please identify the problem and offer and/or correct the problem.+_
Thank you very much for helping a new java wana_be programmer!+_
Below is the source code:+_
*===================*_
import java.awt.*;
import java.awt.MediaTracker;
import java.awt.event.*;
import com.sun.image.codec.jpeg.*;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.geom.GeneralPath;
import java.io.*;
import javax.swing.*;
import javax.imageio.*;
import java.net.URL;
public class JavaPicture{
public BufferedImage bimg;
public JFrame shower = new JFrame();
public ImageIcon imgIcon;
public Canvas canvas;
public Image image;
* Constructor
public void JavaPicture(){
//No picture, no values
public int getWidth(){
return bimg.getWidth();
public int getHeight(){
return bimg.getHeight();
* Load image
public boolean loadImage(String filename){
try{
/*bimg = null;
filename = "file://" + filename;
URL u = new URL(filename);
File f = new File(u.getPath());
bimg = ImageIO.read(f);
Toolkit toolkit = Toolkit.getDefaultToolkit();
image = toolkit.getImage(filename);
MediaTracker mediaTracker = new MediaTracker(shower);
mediaTracker.addImage(image, 0);
try
mediaTracker.waitForID(0);
catch (InterruptedException ie)
//The file did not load
System.err.println(ie);
bimg = new BufferedImage(image.getWidth(null), image.getHeight(null), bimg.TYPE_INT_RGB);
Graphics g = bimg.getGraphics();
g.drawImage(image, 0, 0, null);
return true;
catch (Exception e) {return false;}
public void createNewImage(int width, int height){
bimg = null;
bimg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
public void repaintImage(){
if (shower.isVisible()){
imgIcon.setImage(bimg.getScaledInstance(bimg.getWidth(), bimg.getHeight(), Image.SCALE_FAST));
shower.repaint();
public void showPictureWithTitle(String s){
if (shower.isVisible()){
imgIcon.setImage(bimg.getScaledInstance(bimg.getWidth(), bimg.getHeight(), Image.SCALE_FAST));
shower.setTitle(s);
shower.repaint();
else {
shower = new JFrame(s);
imgIcon = new ImageIcon(bimg.getScaledInstance(bimg.getWidth(), bimg.getHeight(), Image.SCALE_FAST));
shower.getContentPane().add(new JLabel(imgIcon));
shower.setResizable(false);
shower.pack();
shower.show();
* Saves the image represented by the JavaPicture object onto disk.
* @param newfilename the file name to save to
* @exception java.io.IOException raised if the save fails
public boolean saveImage(String newfilename) throws java.io.IOException
FileOutputStream out;
JPEGImageEncoder jpeg;
File filen;
try {
filen = new File(newfilename);
//if (filen.canWrite()){
//return false;}
out = new FileOutputStream(filen);
catch (Exception e){
System.out.println("Sorry -- that filename ("+newfilename+") isn't working");
return false;
try {
jpeg = JPEGCodec.createJPEGEncoder(out);
catch (Exception e) {
System.out.println("Unable to create a JPEG encoder");
return false;
JPEGEncodeParam param = jpeg.getDefaultJPEGEncodeParam(bimg);
param.setQuality(1.0f,true);
jpeg.encode(bimg,param);
out.close();
return true;
* Returns the pixel value of a pixel in the picture, given its coordinates.
* @param x the x coordinate of the pixel
* @param y the y coordinate of the pixel
* @return the pixel value as an integer
public int getBasicPixel(int x, int y)
// to access pixel at row 'j' and column 'i' from the upper-left corner of
// image.
return bimg.getRGB(x,y);
* Sets the value of a pixel in the picture.
* @param x the x coordinate of the pixel
* @param y the y coordinate of the pixel
* @param rgb the new rgb value of the pixel
public void setBasicPixel(int x, int y, int rgb)
bimg.setRGB(x,y,rgb);
* Returns a JavaPixel object representing a pixel in the picture given its coordinates
* @param x the x coordinates of the pixel
* @param y the y coordinates of the pixel
* @return a JavaPixel object representing the requested pixel
public JavaPixel getPixel(int x, int y)
return new JavaPixel(this,x,y);
* Test Main
*@param String[] argvs
public static void main(String[] args)
JavaPicture p = new JavaPicture();
//p.createNewImage(100,100);
//p.showPicture();
p.loadImage("D:\\public_html\\Apache2\\webroot\\webpage\\atlanta_skyline.jpg");
p.showPictureWithTitle("Test");
}Try this.
import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGEncodeParam;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
public class JavaPicture{
public BufferedImage bimg;
public JFrame shower = new JFrame();
public ImageIcon imgIcon;
public Canvas canvas;
public Image image;
Constructor
public void JavaPicture(){
//No picture, no values
public int getWidth(){
return bimg.getWidth();
public int getHeight(){
return bimg.getHeight();
Load image
public boolean loadImage(String filename){
try{
bimg = null;
filename = "file://"+ filename;
URL u = new URL(filename);
File f = new File(u.getPath());
bimg = ImageIO.read(f);
Toolkit toolkit = Toolkit.getDefaultToolkit();
image = toolkit.getImage(filename);
MediaTracker mediaTracker = new MediaTracker(shower);
mediaTracker.addImage(image, 0);
try
mediaTracker.waitForID(0);
catch (InterruptedException ie)
//The file did not load
System.err.println(ie);
bimg = new BufferedImage(image.getWidth(null), image.getHeight(null), bimg.TYPE_INT_RGB);
Graphics g = bimg.getGraphics();
g.drawImage(image, 0, 0, null);
return true;
catch (Exception e) {return false;}
public void createNewImage(int width, int height){
bimg = null;
bimg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
public void repaintImage(){
if (shower.isVisible()){
imgIcon.setImage(bimg.getScaledInstance(bimg.getWidth(), bimg.getHeight(), Image.SCALE_FAST));
shower.repaint();
public void showPictureWithTitle(String s){
if (shower.isVisible()){
imgIcon.setImage(bimg.getScaledInstance(bimg.getWidth(), bimg.getHeight(), Image.SCALE_FAST));
shower.setTitle(s);
shower.repaint();
else {
shower = new JFrame(s);
imgIcon = new ImageIcon(bimg.getScaledInstance(bimg.getWidth(), bimg.getHeight(), Image.SCALE_FAST));
shower.getContentPane().add(new JLabel(imgIcon));
shower.setResizable(false);
shower.pack();
shower.show();
Saves the image represented by the JavaPicture object onto disk.
@param newfilename the file name to save to
@exception java.io.IOException raised if the save fails
public boolean saveImage(String newfilename) throws java.io.IOException
FileOutputStream out;
JPEGImageEncoder jpeg;
File filen;
try {
filen = new File(newfilename);
//if (filen.canWrite()){
//return false;}
out = new FileOutputStream(filen);
catch (Exception e){
System.out.println("Sorry -- that filename ("+newfilename+") isn't working");
return false;
try {
jpeg = JPEGCodec.createJPEGEncoder(out);
catch (Exception e) {
System.out.println("Unable to create a JPEG encoder");
return false;
JPEGEncodeParam param = jpeg.getDefaultJPEGEncodeParam(bimg);
param.setQuality(1.0f,true);
jpeg.encode(bimg,param);
out.close();
return true;
Returns the pixel value of a pixel in the picture, given its coordinates.
@param x the x coordinate of the pixel
@param y the y coordinate of the pixel
@return the pixel value as an integer
public int getBasicPixel(int x, int y)
// to access pixel at row 'j' and column 'i' from the upper-left corner of
// image.
return bimg.getRGB(x,y);
Sets the value of a pixel in the picture.
@param x the x coordinate of the pixel
@param y the y coordinate of the pixel
@param rgb the new rgb value of the pixel
public void setBasicPixel(int x, int y, int rgb)
bimg.setRGB(x,y,rgb);
Returns a JavaPixel object representing a pixel in the picture given its coordinates
@param x the x coordinates of the pixel
@param y the y coordinates of the pixel
@return a JavaPixel object representing the requested pixel
public JavaPixel getPixel(int x, int y)
return new JavaPixel(this,x,y);
Test Main
@param String[] argvs
public static void main(String[] args)
JavaPicture p = new JavaPicture();
//p.createNewImage(100,100);
//p.showPicture();
p.loadImage("D:\\public_html\\Apache2\\webroot\\webpage\\atlanta_skyline.jpg");
p.showPictureWithTitle("Test");
} Rasa -
Exception in thread "main" java.lang.NoClassDefFoundError. I have set the path and classpath but in user variables. And defined main in my programs. But programs are only compiling not running.
Please suggest me.
What do I do?
Edited by: Ram-Murthy on Apr 10, 2008 2:23 AMMake sure your main is static.
public static void main(String [] args) {} -
I am not able to run JSP program
hi
I have done some jsp programs. i have installed tomcat 5. but when i tries to
execute jsp program it gives error as " Unable to get jstl ". it is not getting jasper-comppile.jar file.
Please any one can tell me how to specify path for jasper-compile.jar
thanking youSet the proper classpath.
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jasper-howto.html#Configuration -
I'm not able to run a simple Hello Program in java
I have just now installed jdk 1.3.1_2.
I have set the path and class path.
I'm able to compile the class without any errors but am not able to run the program.
when i say java Hello(after compiling Hello.java), i'm seeing the following error:
Exception in thread "main" java.lang.NoclassDefFoundError:Hello
Thanks in advance in this regardHmm..
Okay.. set aside any import or package stuffs.. lets say about a simple HelloWorld program which is called Hello.class. It resides in c:\, which means the full path is c:\Hello.class.
Make sure you got one of your path as c:\jdk1.3\bin(assuming you are using jdk 1.3).
If you are in the same directory as Hello.class, which is c:\>, you can execute the class file by typing:
C:\>java Hello
If you are not in the same directory and you wishes to run the class file, example you are in directory temp now:
C:\Temp>java -cp C:\ Hello
So the cp set will be just c:\. Hope that answers your question somehow.. well... if I never intepret it wrongly. -
I'm having trouble connecting to apps, itunes store, internet on my iPhone 5 running iOS 7.0.4. I am currently connected to a perfectly running WiFI connection. This just started happening today (2/19/14)! Why am I not able to connect anything? I've tried ALL the fixes suggested. HELP!!!!!!!!! BTW, I know my Wi-Fi connection is good because I'm using it on my desktop and other people in my office are also connected on their iPhones and desktops. Again, HELP!!!!
You may not really be connected to your WiFi network.
Your router may not have given your iPhone a valid IP address. Go to Settings > Wifi > your network name and touch the "i" to the right to see the network details. If the IP address starts with 169 or is blank then your router didn't provide an IP address and you won't be able to access the Internet.
Sometimes the fix can be as simple as restarting your router (remove power for 30 seconds and restart). Next, reset network settings on your iPhone (Settings > General > Reset > Reset network settings) and then attempt to connect. In other cases it might be necessary to update the router's firmware with the latest from the manufacturer's support web pages.
If you need more help please give more details on your network, i.e., your router make, model and version, the wifi security being used (WEP, WPA, WPA2), etc. -
i'm trying to redeem my itunes gift card and i get the message "session timed out." does anyone know why i'm not able to redeem my card and why i get this message in stead?
I've been having the same issues too, and thought it was just my outdated computer or account?!
Every time I try to purchase a song, "session has timed out" shows up after I click "agree" to the terms!? I seem to be in the exact same scenario as 'SportsBarn' above: Itunes support have replied repeatedly with the same "solutions" but nothing has helped or even been applicable. I have an older laptop, 2005 Powerbook running OS X 10.4 Tiger so it's not compatible with the latest iTunes 10.5.2 which requires minimum OS X 10.5. I've been using the balance already in my iTunes account (from redeemed giftcards over the past few years) with no problem, until recently (my last successful purchase was October 2011). I wonder if it's the older OS or just a redemption glitch even with newer computers? -
I have an imac 2006 running 10.6.8 but I still can't upgrade to Mavericks. Is this model not able to run mavericks, or is there a way to download? Apple says any imac running snow leopard or later.
Again, some proof would be nice
Instead of just making a casual, blanket statement, why don't you just post the actual install procedure here, then.
Also, the 2006 models really do not have sufficient RAM specs to run Mavericks well.
So, I seriously question that your 2006 model iMac is running well on Mavericks.
2006 models could either take 2 or 3 GBs of RAM (you can install 4 GBs of RAM to take advantage of more efficient RAM processing of matched pairs of RAM, but the hardware will only recognize 3.2 to 3.4 GBs of that total RAM). This is barely the needed "real world" "working" minimum of RAM needed for Mavericks to run adaequately.
New iMacs ship with a much better 8 GBs of RAM.
If you can't offer/post proof with an actual install procedure for installing Mavericks on unsupported Macs, then I would suggest you stop posting your assertion that
"I have done it" garbage and post knowledge and info that is REAL and relevant to users of 2006 model Macs that need accurate info about this. -
please , help me for apple id....... i made new id but there is a credite card option and that's why i am not able to download any free application for iphone,.....so,.....what i do about this problem..???
You can create an Apple ID without a credit card by following this guide exactly: http://support.apple.com/kb/ht2534. Note that you have to start by downloading a free app, then create the ID.
-
Hi can any body please tell me how to open the .exe files in mac and why it is not supported with unarchiever app , also i am not able to run and dvd's in my mac its not accepting any cd's or dvd'd why? do i need to do some pre defined settings to run the cd's and dvd's ?
A .exe file is a Windows executable. OS X does not run Windows programs. If you need to use .exe files then you will need to install Windows on your Mac:
Windows on Intel Macs
There are presently several alternatives for running Windows on Intel Macs.
Install the Apple Boot Camp software. Purchase Windows XP w/Service Pak2, Vista, or Windows 7. Follow instructions in the Boot Camp documentation on installation of Boot Camp, creating Driver CD, and installing Windows. Boot Camp enables you to boot the computer into OS X or Windows.
Parallels Desktop for Mac and Windows XP, Vista Business, Vista Ultimate, or Windows 7. Parallels is software virtualization that enables running Windows concurrently with OS X.
VM Fusionand Windows XP, Vista Business, Vista Ultimate, or Windows 7. VM Fusion is software virtualization that enables running Windows concurrently with OS X.
CrossOver which enables running many Windows applications without having to install Windows. The Windows applications can run concurrently with OS X.
VirtualBox is a new Open Source freeware virtual machine such as VM Fusion and Parallels that was developed by Solaris. It is not as fully developed for the Mac as Parallels and VM Fusion.
Note that Parallels and VM Fusion can also run other operating systems such as Linux, Unix, OS/2, Solaris, etc. There are performance differences between dual-boot systems and virtualization. The latter tend to be a little slower (not much) and do not provide the video performance of the dual-boot system. See MacTech.com's Virtualization Benchmarking for comparisons of Boot Camp, Parallels, and VM Fusion. Boot Camp is only available with Leopard or Snow Leopard. Except for Crossover and a couple of similar alternatives like DarWine you must have a valid installer disc for Windows.
You must also have an internal optical drive for installing Windows. Windows cannot be installed from an external optical drive.
Maybe you are looking for
-
We are trying to use an ipad to replace ordinary paper sheet music on a piano. When truning ordinary paper pages, it is sometimes hard to grasp one page, turn it quickly and get it to stay turned. The idea with using an ipad is that a tap turns the
-
How to migrate Mac Pro to MacBook Pro?
After cloning my Mac Pro Boot Camp XP2 to my MacBook Pro via Netrestore I realized I'm not sure how to deal with the hardware differences. XP boots fine on the MacBook Pro but has no trackpad, and no USB mouse support. I tried to reinstall "Boot camp
-
Hello Experts - can anyone please help with the following? I am trying to import some BP details through the DTW. Part of the import will need to populate the Accounts Receivable field on the accounting tab of the BP record. Currently, it doesn't mat
-
Extension libs in Tomcat .war
Hi all. After researching ANT for a bit, and the ins-and-outs of .war files, I'm feeling a bit more adventerous with deploying web apps via JWS. I've been studying the very good Sun/Oracle tutorials on deploying apps via Web Start, but I'm stuck on t
-
I am new with Oracle and require the reference manual to find out more about join conditions. I have some difficulty finding a document from the Oracle web on SQL reference.