Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6732345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:38:21+00:00 2026-05-26T10:38:21+00:00

I am trying to read and write to the parallel port, I implemented the

  • 0

I am trying to read and write to the parallel port, I implemented the writing and reading in C, now I want to import that code into a java GUI application.
I managed to include the C .so file into the java project and when calling the functions directly in the Java solutions main() method they work just fine.

I tried to call the native functions when a button is pressed, but it won’t work, the application crashes. I am running the application as root, root priviledge is needed to change and read the parallel ports values.

How I am trying to call the native function:

 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
       try
       {
           int portNR=Integer.parseInt(jTextField1.getText());
           int value=Integer.parseInt(jTextField2.getText());
        ParalellComanderApp.setPort(portNR,value );
       }
       catch (Exception e)
       {
           System.err.println(e.getMessage());
       }
    }

The Native function in C:

JNIEXPORT void JNICALL Java_paralellcomander_ParalellComanderApp_setPort
  (JNIEnv *env, jobject obj, jint port, jint value)
{
     outb(value,MAIN_PORT+port); 
     printf("Setting port %d to value %d\n",port,value);
}

Crash message:

    A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f00adaf9833, pid=6516, tid=139640785835776
#
# JRE version: 6.0_23-b23
# Java VM: OpenJDK 64-Bit Server VM (20.0-b11 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea6 1.11pre
# Distribution: Ubuntu oneiric (development branch), package 6b23~pre10-0ubuntu5
# Problematic frame:
# C  [libAccessParalel.so+0x833]  inb+0x17
#
# An error report file with more information is saved as:
# /home/bari/NetBeansProjects/ParalellComander/dist/hs_err_pid6516.log
#
# If you would like to submit a bug report, please include
# instructions how to reproduce the bug and visit:
#   https://bugs.launchpad.net/ubuntu/+source/openjdk-6/
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.

Sorry for the long post.
Can anybody help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:38:21+00:00Added an answer on May 26, 2026 at 10:38 am

    Rather than using JNI and running your GUI as root, I would make the C part into a stand alone program (that runs with the bare minimum privileges – i.e. it binds to the parallel port and then revokes all other privileges) which talks to the Java app over a network socket. That way you have more control over what passes between the part that faces the end user and the part that has elevated privileges, and are less vulnerable to attack. It would also be easier to debug and test, because you can test the network communication to the C program using telnet or netcat without even involving the GUI part.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read and write the data to the server using java program.
I'm using read/write locks on Linux and I've found that trying to upgrade a
I am trying to read in a string from a C# Response.Write(string example) into
I'm trying to write a short function that will let me quickly read in
I'm trying to read and write to a usb modem that is using the
I have a NSString declared in my AppDelegate. I am trying to read/write that
I am trying to write code that unzips a zip archive and places the
I am trying to create-read/write a file into a subfolder of the users AppData\Roaming
I am trying to write some code that does AES decryption for an SSL
Currently am trying to read and write mp3 tags without using any external modules

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.